How to seed a model (using the seed-fu gem) that has been translated using the globalize3 gem (Rails)
-
27-06-2021 - |
Frage
In a Ruby on Rails app, how would one seed a model (using the seed-fu gem) that has been translated using the globalize3 gem?
I tried seeding both the table and translated table with the code below, but it didn't work.
fixtures:
products.rb
Product.seed(:id,
{ :id => 1 }
)
product_translation.rb
Product_translation.seed(:id,
{ :id => 1, :product_id => 1, :locale => "en", :name => "foo"},
{ :id => 2, :product_id => 1, :locale => "ja", :name => "bar"}
)
Lösung
I've never used seed-fu, but I know globalize3 fairly well and Product_translation
doesn't look right to me. Shouldn't it be Product::Translation
(or Product.translation_class
)?
Maybe this would work:
product_translations.rb
Product::Translation.seed(:id,
{ :id => 1, :product_id => 1, :locale => "en", :name => "foo"},
{ :id => 2, :product_id => 1, :locale => "en", :name => "bar"}
)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow