我正在尝试使用
<%= comment.created_at.time_ago_in_words(from_time) %>
但它行不通。我希望评论显示日期为:3分钟前或2天前。
使用此助手的正确方法是什么?
在我的布局助手中:
def time_ago_in_words(from_time, include_seconds_or_options = {})
distance_of_time_in_words(from_time, Time.now, include_seconds_or_options)
end
谢谢!
最佳答案
http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_ago_in_words
所以应该
<%= time_ago_in_words(comment.created_at) %>
关于ruby-on-rails - 时间前在created_at?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24489747/