How to seed a model (using the seed-fu gem) that has been translated using the globalize3 gem (Rails)

StackOverflow https://stackoverflow.com/questions/12076910

문제

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"}
 )
도움이 되었습니까?

해결책

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"}
)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top