Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

time_ago_in_words => "in {{count}} days."?

I'm having a very weird bug. In my code I have <%= time_ago_in_words(game.created_at) %>

It's works locally and on my staging server but NOT on my production server:

Example: http://hockey-community.com/games/show/45

I get "in {{count}} days."

Weirdly, if the number returned is 1, it works. (ex: 1 hour ago or 1 day ago).

Any idea would be very helpful. Thks

like image 973
Alextoul Avatar asked Dec 02 '10 00:12

Alextoul


2 Answers

Rails was using some deprecated syntax in the helper which then got dropped in the latest Ruby version. If you are using something like Heroku, try telling your production instance to use Rails 2.3.9. Otherwise you can also try downgrading Ruby.

See the changelog: http://weblog.rubyonrails.org/2010/9/4/ruby-on-rails-2-3-9-released

Changes i18n named-interpolation syntax from the deprecated Hello {{name}} to the 1.9-native Hello %{name}.

This looks like it will fix your problem.

like image 186
smudge Avatar answered Sep 24 '22 19:09

smudge


It sounds to me like you don't have the same version of Ruby in Production as you do in Development. Personally I still have Ruby 1.8.7 in my Development and in the Console, I constantly get the following message when I use time_ago_in_words:

The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.

Now this message about deprecated does not come from Rails, it comes from Ruby. And since time_ago_in_words is a Rails helper, it seems like this feature in Rails is not compatible with the later versions of Ruby where this has been removed.

So unless you manually want to monkey patch the actual helper in some way (I wouldn't recommend it) you can either upgrade Rails or downgrade Ruby so that they are compatible.

like image 29
DanneManne Avatar answered Sep 22 '22 19:09

DanneManne