我有一个问题,我刚刚使用time_ago_in_words遇到(出于某种原因).发表帖子后,我得到了
translation data {"one"=>"1 minute", "other"=>"{{count}} minutes"} can not be used with :count => 9
Run Code Online (Sandbox Code Playgroud)
我也没有做任何有趣的事情,只是调用一个小帮助函数
def friendly_publish_date(post)
return '' if post.publish_date.nil?
if post.publish_date >= 1.day.ago
"#{time_ago_in_words post.publish_date} ago"
else
post.publish_date
end
end
Run Code Online (Sandbox Code Playgroud)
现在,这已经很好地工作了很长时间,然后我尝试今天早上发布一个帖子,它开始抛出先前的异常.有任何想法吗?
编辑:再次发生,所以这里是一个完整的堆栈跟踪请求.
Processing PostsController#index (for 74.213.163.234 at 2010-01-05 11:43:26) [GET]
Parameters: {"action"=>"index", "controller"=>"posts"}
Rendering template within layouts/application
Rendering posts/index
ActionView::TemplateError (translation data {"one"=>"less than a minute", "other"=>"less than {{count}} minutes"} can not be used with :count => 1) on line #5 of app/views/posts/_post.html.erb:
2: <header>
3: <div …Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的问题,希望有人知道问题是什么......
使用distance_of_time_in_words(以及因此time_ago_in_words)不返回实际时间距离.相反,它返回的内容包括"en,about_x_hours"或"en,x_minutes".
模式是正确的,如:
time_ago_in_words(50.minutes.ago) => "en, about_x_hours"
time_ago_in_words(3.minutes.ago) => "en, x_minutes"
Run Code Online (Sandbox Code Playgroud)
但是,为什么它在显示"x"而不是实际数字,"_"而不是空格,以及"en",在所有这些的开头?!