ruby on rails 3 - Do I need to keep the fields for my polymorphic address in the view to make accepts_nested_attributes_for work? -


i have problem classes posted server not saved , can't figure out why , appreciate in matter.

first of take account class has reference address , defines both billing , delivery address.

class account < activerecord::base   has_many :addresses, :as => :addressable, :dependent => :destroy   has_one :billing_address, :as => :addressable   has_one :delivery_address, :as => :addressable   accepts_nested_attributes_for :billing_address,     :allow_destroy  => true,     :reject_if      => missing_attrs?('street_one', 'zip', 'city', 'country_id')    accepts_nested_attributes_for :delivery_address,     :allow_destroy  => true,     :reject_if      => missing_attrs?('street_one', 'zip', 'city', 'country_id') end 

now address classes follows

class address < activerecord::base     belongs_to :country   belongs_to :addressable, :polymorphic => true     validates_inclusion_of :type, :in => %w(billingaddress deliveryaddress ), :message => "please speficy either billing or delivery address"   attr_accessor :street_one, :street_two, :zip, :city, :country_id, :region end     class billingaddress < address end  class deliveryaddress < address end 

then have view following form , must perfect in browser, fields there , names correc array elelments , all.

=semantic_form_for [:admin,@account] |f|             = render 'shared/errors', :target => @account   =f.inputs                            =f.semantic_fields_for :billing_address |address|        =address.inputs name:"billing address"         =address.input :street_one         =address.input :street_two         =address.input :city         =address.input :zip         =address.input :region         =address.input :country       =f.semantic_fields_for :delivery_address |address|        =address.inputs name:"delivery address"         =address.input :street_one         =address.input :street_two         =address.input :city         =address.input :zip         =address.input :region         =address.input :country                            =f.semantic_fields_for :users |user|                               =user.inputs name:"default user"       =user.input :email       =user.input :password   =f.submit 

if check raise params.to_yaml correct though polymorphic fields addressable , type missing. guess since build in controller need keep them in view before post them controller before update , create. read this post can't figure out does.

can have best suggestions please?

i added missing fields in form , it's working perfectly!


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -