Jse*_*seb 0 ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1
前一段时间用语言给我一个堆栈错误太深的错误.我在这里怎么称呼它.
<%= link_to time_ago_in_words(f.created_at), f %>
Run Code Online (Sandbox Code Playgroud)
这就是我在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
Run Code Online (Sandbox Code Playgroud)
我不能重新定义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
Run Code Online (Sandbox Code Playgroud)
原版的:
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
Run Code Online (Sandbox Code Playgroud)
你仍然有一个反复调用自己的功能.我认为你的意思是代替最后一行:
"happened #{time_ago_in_words(time)} ago"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
903 次 |
| 最近记录: |