distance_of_time_in_words with ActiveRecord TimeWithZone
I'm trying to use distance_of_time_in_words
(Rails 3) on a created_at
column of an A开发者_如何学GoctiveRecord object.
But I get
ActiveSupport::TimeWithZone can't be coerced into Fixnum
when I call
distance_of_time_in_words(@user.created_at)
Any ideas?
You need to supply the to_time
as well. Assuming you want to know "how long ago from right now":
<%= distance_of_time_in_words(@user.created_at, Time.now) %>
Alternatively, you could just do this:
<%= distance_of_time_in_words_to_now(@user.created_at) %>
精彩评论