For example, why are the date helpers written like this:
time_ago_in_words(@from_time)
Instead of like this:
@from_time.time_ago_in_words
Is this a clear design error / inconsistency? Or is there some reason for this?
For example, why are the date helpers written like this:
time_ago_in_words(@from_time)
Instead of like this:
@from_time.time_ago_in_words
Is this a clear design error / inconsistency? Or is there some reason for this?
Great question!
Most of the helpers are for selecting dates / times.
http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html
I'm guessing whoever wrote it wanted a couple of util methods and so added time_ago_in_words and distance_of_time_in_words to their helper with the selects.
As time_ago_in_words and distance_of_time_in_words are presentaton focused (i.e. you may want to localize it) the developer maybe felt that the helper isn't a bad place for them.
Helpers are methods on the view object, rather than on the object they're displaying. This makes sense in an OO sense because the view is displaying the data in a particular format, so it's in charge of converting the models to that format.