我正在尝试distance_of_time_in_words在created_atActiveRecord对象的列上使用(Rails 3).
但我明白了
ActiveSupport::TimeWithZone can't be coerced into Fixnum
Run Code Online (Sandbox Code Playgroud)
我打电话的时候
distance_of_time_in_words(@user.created_at)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
你也需要提供to_time.假设你想知道"从现在开始多久":
<%= distance_of_time_in_words(@user.created_at, Time.now) %>
Run Code Online (Sandbox Code Playgroud)
或者,您可以这样做:
<%= distance_of_time_in_words_to_now(@user.created_at) %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1904 次 |
| 最近记录: |