我目前在我的应用程序中有这个代码:
def comment_poster(comment)
if comment.user
"posted by #{comment.user.username} #{time_ago_in_words(comment.created_at)} ago"
else
"posted by anonymous"
end
end
但是,这只适用于我在几秒钟前和几年前发布的内容:
posted by teejay about 1 year ago
posted by teejay about 1 month ago
当我几天前编辑created_at值时,它给了我:
posted by thorpe {{count}} days ago
我应该怎么做才能让它发挥作用而失去{{count}}
编辑:我使用的是Rails 2.3.5,如果这意味着什么
编辑:#2
我通过在config/locales/en.yml
datetime:
distance_in_words:
half_a_minute: "half a minute"
less_than_x_seconds:
one: "less than 1 second"
other: "less than %{count} seconds"
x_seconds:
one: "1 second"
other: "%{count} seconds"
less_than_x_minutes:
one: "less than a minute"
other: "less than %{count} minutes"
x_minutes:
one: "1 minute"
other: "%{count} minutes"
about_x_hours:
one: "about 1 hour"
other: "about %{count} hours"
x_days:
one: "1 day"
other: "%{count} days"
about_x_months:
one: "about 1 month"
other: "about %{count} months"
x_months:
one: "1 month"
other: "%{count} months"
about_x_years:
one: "about 1 year"
other: "about %{count} years"
over_x_years:
one: "over 1 year"
other: "over %{count} years"
almost_x_years:
one: "almost 1 year"
other: "almost %{count} years"
prompts:
year: "Year"
month: "Month"
day: "Day"
hour: "Hour"
minute: "Minute"
second: "Seconds"
任何人都可以解释这个问题是什么吗?
答案 0 :(得分:7)
问题在于i18n gem版本。如果你降级到0.4.1,这个问题就会消失。
问题是从版本0.4.1开始,访问变量的方式不再是{{variable}}。