我正在用Rails 3编写一个引擎。我有一个generic_recipe包含这样的食谱:
module EdibleRecipe
class GenericRecipe < ActiveRecord::Base
attr_accessible :recipe, :recipe_attributes, ....
has_many :recipes
accepts_nested_attributes_for :recipes
end
end
表单正确呈现:
<%= f.fields_for :recipe do |r| %>
...
但是在保存时,我得到了:
ActiveRecord::UnknownAttributeError in EdibleRecipe::GenericRecipesController#create
Full code is here。非常感谢任何帮助:)
答案 0 :(得分:0)
使用
attr_accessible :recipes_attributes
而不是:recipe_attributes