使用time_ago_in_words获取{{count}}

Tee*_*eej 4 ruby-on-rails

我目前在我的应用程序中有这个代码:

  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
Run Code Online (Sandbox Code Playgroud)

但是,这只适用于我在几秒钟前和几年前发布的情况:

posted by teejay about 1 year ago
posted by teejay about 1 month ago
Run Code Online (Sandbox Code Playgroud)

当我几天前编辑created_at值时,它给了我:

posted by thorpe {{count}} days ago
Run Code Online (Sandbox Code Playgroud)

我该怎么办才能使它发挥作用而失去它 {{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"
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释这个问题是什么?

nun*_*nia 7

问题出在i18n gem版本上.如果降级到0.4.1,这个问题就会消失.

问题是从版本0.4.1开始,访问变量的方式不再是{{variable}}.