I’m new to Rails so I apologize if this is a dumb question. I have view and I want to display the time ago using (http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_ago_in_words). Do I use this in my view or my controller?
Share
You can use this Helper directly in your view. You don’t need to declare ActionView anywhere, just place it in your view like this
<%= time_ago_in_words(10.minutes) %>, replacing the10.minuteswith whatever suits your particular use case.The parameter (10.minutes) is therefore the ‘from’ and the ‘to’ is implied and not a parameter as it is fixed to
Time.now.