Kaspar Schiess wrote:
> Dear List,
> 
> Can somebody enlighten me as to why a WrongLanguageError is thrown when
> I access a stale copy of a model? I fully understand why such an error
> is required upon writing to the object, but on read access? It seems to
> make code more complicated than it needs be. Probably there is some
> blindingly obvious reason for this that helps me see it.
> 
> -- code example --
> Globalize::Locale.set_base_language 'en-US'
> 
> p = Page.find(1) #�returns an english page
> Globalize::Locale.set 'fr-CH'  # p is now the 'wrong' language
> puts p.title # This throws WrongLanguageError. Why? The value is 
> perfectly ok!
> -- code example --

because you have to reload your object before. the correct language is 
loaded with the 'find', and with the access reader method.

  ...
  Globalize::Locale.set 'fr-CH'
  p = Page.find(1)
  puts p.title

will be ok.

> 
> Thank you for any answer you might have.
> kaspar
> --
> neotrivium.com - the swiss ruby shop


-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Railsi18n-discussion mailing list
Railsi18n-discussion@rubyforge.org
http://rubyforge.org/mailman/listinfo/railsi18n-discussion

Reply via email to