Getting {{count}} using time_ago_in_words

I am currently using this code in my application:

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 

However, this only works when I posted a few seconds ago and a few years ago:

 posted by teejay about 1 year ago posted by teejay about 1 month ago 

When I edit the created_at value a few days ago, it gives me the following:

 posted by thorpe {{count}} days ago 

What should I do for this to make it work and lose that {{count}}

Edit: I am using Rails 2.3.5 if that means something

Edit: # 2

I fixed the problem by inserting this code in 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" 

Can someone explain what the problem is?

+4
source share
1 answer

Problem with i18n gem version. If you downgrade to 0.4.1, this problem will disappear.

The fact is that starting with version 0.4.1, the way to access variables is no longer {{variable}}.

+7
source

Source: https://habr.com/ru/post/1337459/


All Articles