在Ruby on Rails应用程序中,如何为使用globalize3 gem翻译的模型(使用seed-fu gem)播种?
我尝试使用下面的代码播种表和翻译表,但它没有用。
夹具:
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"}
)
答案 0 :(得分:1)
我从未使用过seed-fu,但我对globalize3的了解相当不错,而Product_translation
对我来说并不合适。不应该是Product::Translation
(或Product.translation_class
)吗?
也许这会奏效:
<强> 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"}
)