Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Globalize2 'n' rails 2.2.2 issue
2 Posts
Globalize2 'n' rails 2.2.2 issue

hey guyz,

I got work around for that. The actual problem is my I18n.fallbacks are always returning nil values.....that means

@@fallbacks = nil
def fallbacks
      @@fallbacks ||= Globalize::Locale::Fallbacks.new
    end

This is not working at all from there and returning error to me.

So, I did a work around for that

@@fallbacks = []
 def fallbacks
@@fallbacks = @@fallbacks[I18n.locale.to_sym].blank? ? map_fallbacks : @@fallbacks
end

def map_fallbacks
return {I18n.locale.to_sym=>[I18n.locale.to_sym, :en_US, :root]}.merge(@@fallbacks)
end

It works for me.

Hey guyz,

Currently i'm using globalize2 plugin in one of my project. Its working fine while saving the data. As,

I18n.locale = "en"
gn = Genre.create(:title=>"drama")
I18n.locale = "it"
gn.title = "dramea"
gn.save!

Its working fine for me. It creates 2 corresponding entries in the genre_translations table as well

But problem is while searching for the record the globalize thingy is not working properly. As


I18n.locale = "en"
gn = Genre.find(:first)
gn.title or gn[:title]
=>dramea
I18n.locale = "it"
gn = Genre.find(:first)
gn.title or gn[:title]
=>dramea

In both the cases its giving the same result, the record which i entered the last.....?????????

All kind of help is invited.

2 Posts
Login to add your message