ruby on rails 3 - Can't mass-assign protected attributes for Nested simple_form -
i have form nests store fields within seller fields. this
= simple_form_for @seller, url: pages_path |f| .span3 h5.capital personal/contact details = f.input :name, label: false, placeholder: 'full name (owner/manager)' = f.input :mobile, label: false, placeholder: 'mobile phone no.' = f.input :landline, label: false, placeholder: 'landline no. (with std code)' = f.input :email, label: false, placeholder: 'email id' .span5 h5.capital store details = f.simple_fields_for :store_attributes |builder| = builder.input :name, label: false, placeholder: 'store name' = builder.input :address, label: false, placeholder: 'full address' = builder.input :city, label: false, placeholder: 'city/district', = builder.input :pincode, label: false, placeholder: 'pincode', class: 'pincode' = builder.input :website, label: false, placeholder: 'website/facebook page'
and seller model looks this
class seller < user attr_accessible :landline, :mobile, :name, :store_attributes has_one :store accepts_nested_attributes_for :store validates :name, presence: true validates :mobile, presence: true validates :landline, presence: true end
here controller code
def create @seller = seller.new(params[:seller]) @store = store.new(params[:store]) if @seller.save & @store.save redirect_to @seller else render 'home' end end
and when submit form , following error
activerecord::unknownattributeerror in pagescontroller#create unknown attribute: seller_id
please guide me on how has resolved while keeping whitelist_attributes = true.
many thx.
Comments
Post a Comment