2012-05-18 26 views
1

我遇到了一个新手面临Rails 3.2.3的常见问题。我收到错误嵌套形式的质量分配失败

无法大规模指派保护的属性:user_impl,util_location

class User < ActiveRecord::Base 

    has_one :user_impl, :dependent => :destroy 
    has_one :util_location, :as => :locatable, :dependent => :destroy 

    attr_accessible ..., :user_impl_attributes, :util_location_attributes 

我尝试添加accepts_nested_attributes_for:user_impl,:util_location的代码太,但同样没有工作,一个完全放弃不同的错误。

回答

1

的基本结构应如下:

class User < ActiveRecord::Base 
    attr_accessible :user_impl_attributes 

    has_one :user_impl, :dependent => :destroy 
    accepts_nested_attributes_for :user_impl