I\'m writing a Rails application, but can\'t seem to find how to do relative time, i.e. if given a certain Time class, it can calculate \"30 seconds ago\" or \"2 days ago\"
Since the most answer here suggests time_ago_in_words.
Instead of using :
<%= time_ago_in_words(comment.created_at) %>
In Rails, prefer:
<%= comment.created_at.to_s %>
along with a jQuery library http://timeago.yarp.com/, with code:
$("abbr.timeago").timeago();
Main advantage: caching
http://rails-bestpractices.com/posts/2012/02/10/not-use-time_ago_in_words/