2013-03-29 102 views
0

我正在寫使用Rails 3引擎的時候,我有沒有包含這樣的食譜generic_recipe:未知屬性保存嵌套形式

<%= f.fields_for :recipe do |r| %> 
... 

module EdibleRecipe 
    class GenericRecipe < ActiveRecord::Base 
    attr_accessible :recipe, :recipe_attributes, .... 
    has_many :recipes 
    accepts_nested_attributes_for :recipes 
    end 
end 

的形式正確地呈現

但保存時,我得到:

ActiveRecord::UnknownAttributeError in EdibleRecipe::GenericRecipesController#create 

Full code is here。任何幫助是極大的讚賞:)

+0

的另一個問題是,我不得不f.fields_for:配方,而不是f.fields_for:食譜我的形式。 – valk

回答

0

使用

attr_accessible :recipes_attributes 

相反的:recipe_attributes