以前的文字是返回给我一个堆栈错误太深的错误。这就是我所说的。
<%= link_to time_ago_in_words(f.created_at), f %>下面是我在article.helper中所做的
def time_ago_in_words(time_str)
time = time_str.to_time + (-Time.zone_offset(Time.now.zone))
"happened #{time_ago_in_words(time)} ago"
end我不能重新定义time_ago_in_words吗?因为我也尝试了下面的方法,它给了我同样的错误
<%= link_to ctime_ago_in_words(f.created_at), f %>
def ctime_ago_in_words(time_str)
time = time_str.to_time + (-Time.zone_offset(Time.now.zone))
"happened #{ctime_ago_in_words(time)} ago"
end发布于 2012-09-01 02:15:49
原件:
def ctime_ago_in_words(time_str)
time = time_str.to_time + (-Time.zone_offset(Time.now.zone))
"happened #{ctime_ago_in_words(time)} ago"
end您仍然有一个反复调用自身的函数。我想你最后一句话的意思是:
"happened #{time_ago_in_words(time)} ago"https://stackoverflow.com/questions/12220577
复制相似问题