Hi,
I'll answer myself.
The problem is that it seems that symbols can't be used to set the
locale. If I use strings instead, the translated fields are retrieved
with no problems.
Regards
Borja Martín escribió:
> Hi,
> I was trying use the new version of the globalize plugin and it seems
> that there is some bug while trying to retrieve a translated field as
> it returns a nil value instead of the translated text.
>
> I have the following migration:
>
> class CreateFoos < ActiveRecord::Migration
> def self.up
> create_table :foos do |t|
> t.timestamps
> end
> create_table :foo_translations, :force => true do |t|
> t.references :foo
> t.string :locale
> t.string :title
> t.timestamps
> end
> end
>
> def self.down
> drop_table :foo_translations
> drop_table :foos
> end
> end
>
> The Foo class looks like this:
>
> class Foo < ActiveRecord::Base
> translates :title
> end
>
> Then I run the following code in the rails console:
> Loading development environment (Rails 2.2.0)
> >> f = Foo.new
> => #<Foo id: nil, created_at: nil, updated_at: nil>
> >> I18n.locale = :"es-ES"
> => :"es-ES"
> >> f.title = 'titulo'
> => "titulo"
> >> f.save
> => true
> >> f.title
> => nil
> >> I18n.locale = :"en-US"
> => :"en-US"
> >> f.title = 'title'
> => "title"
> >> f.save
> => true
> >> f.title
> => nil
>
> As you can see, the title method returns a nil value... However, I
> looked into the foo_translations table and the translations are being
> saved correctly...
> Is there anything I'm missing?
>
> Thanks in advance
> Regards
>
--
/**
* dagi3d v4 -
http://dagi3d.net */