Ruby on rails 没有模型的种子设定转换表,rails应用程序

Ruby on rails 没有模型的种子设定转换表,rails应用程序,ruby-on-rails,seed,globalize3,Ruby On Rails,Seed,Globalize3,我使用的是Ryan Bates railscasts中的Globalize 3 gem,一切正常。但我需要知道如何为数据播种。目前,我使用以下模式创建了一个名为monthly_post_translations的表 schema.rb create_table "monthly_post_translations", :force => true do |t| t.integer "monthly_post_id" t.string "locale" t.text

我使用的是Ryan Bates railscasts中的Globalize 3 gem,一切正常。但我需要知道如何为数据播种。目前,我使用以下模式创建了一个名为monthly_post_translations的表

schema.rb

create_table "monthly_post_translations", :force => true do |t|
  t.integer  "monthly_post_id"
  t.string   "locale"
  t.text     "body"
  t.datetime "created_at"
  t.datetime "updated_at"
end
我需要将种子数据添加到此表中,但它没有可交互的模型,所以我该怎么做

这是我的种子.rb,它不工作了

种子.rb

# Monthly Posts
  MonthlyPost.delete_all

 monthlypost = MonthlyPost.create(:body => "Monthly Post Text")


#Monthly Posts Spanish Translation
monthlytranslation = MonthlyPostTranslation.create(:body => "Spanish Translation of monthly post text",
      :monthly_post_id => monthlypost.id,
      :locale => "es" )
但是每月的翻译表没有一个我可以交互的模型,所以我得到了错误

uninitialized constant MonthlyPostTranslation
关于如何正确添加此种子数据,您有什么想法吗?

通过键入
translations:
您将获得名为
MonthlyPost::Translation
的生成模型。所以答案是:使用实例集合创建或列出实体的所有翻译:

monthlypost = MonthlyPost.create(:body => "Monthly Post Text")


#Monthly Posts Spanish Translation
monthlytranslation = monthlypost.translations.create(:body => "Spanish Translation of monthly post text",
      :locale => "es" )
通过键入
translations:
您将获得名为
MonthlyPost::Translation
的生成模型。所以答案是:使用实例集合创建或列出实体的所有翻译:

monthlypost = MonthlyPost.create(:body => "Monthly Post Text")


#Monthly Posts Spanish Translation
monthlytranslation = monthlypost.translations.create(:body => "Spanish Translation of monthly post text",
      :locale => "es" )

这确实奏效了,非常感谢。但有一个问题,这个MonthlyPost::Translation模型在我的rails应用程序中位于哪里?它是在加载
MonthlyPost
类时为您生成的。确切的位置在
翻译
方法下:这确实有效,非常感谢。但有一个问题,这个MonthlyPost::Translation模型在我的rails应用程序中位于哪里?它是在加载
MonthlyPost
类时为您生成的。确切位置在
翻译方法下: