ruby on rails - Uknown attributes error nested attributes -


i keep getting unknown attributes error, though have tried of similar answers question here. trying update council , property attributes join table council history using nested form, when try load view form error please advice think might doing wrong new rails , programming.

error

started put "/properties/6/build/council" 127.0.0.1 @ 2013-08-19 17:35:45 +0100 processing properties::buildcontroller#update html   parameters: {"utf8"=>"✓",     "authenticity_token"=>"wbwqaxtbioqzglkhurstqs+cfd/xveutxnj0jwntsa0=", "property"=>   {"council_history_attributes"=>{"council_id"=>""}}, "commit"=>"create council history",  "property_id"=>"6", "id"=>"council"}   property load (0.3ms)  select "properties".* "properties" "properties"."id" =  ? limit 1  [["id", "6"]]    (0.1ms)  begin transaction    (0.1ms)  rollback transaction completed 500 internal server error in 6ms  activerecord::unknownattributeerror - unknown attribute: council_history_attributes:   activerecord (3.2.13) lib/active_record/attribute_assignment.rb:88:in `block in  assign_attributes'   activerecord (3.2.13) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'   activerecord (3.2.13) lib/active_record/persistence.rb:216:in `block in update_attributes'   activerecord (3.2.13) lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'   activerecord (3.2.13) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'   activerecord (3.2.13) lib/active_record/transactions.rb:208:in `transaction'   activerecord (3.2.13) lib/active_record/transactions.rb:311:in `with_transaction_returning_status'   activerecord (3.2.13) lib/active_record/persistence.rb:215:in `update_attributes'   app/controllers/properties/build_controller.rb:24:in `update' 

property model

class property < activerecord::base   attr_accessible  :name, :address_attributes, :tenants_attributes, :meter_attributes, :council_history, :council_history_attributes, :property_id, :council_id, :status   belongs_to :user     has_one :council_history    has_one :council, through: :council_history, :foreign_key => :council_id   accepts_nested_attributes_for :council  end 

council model

class council < activerecord::base   attr_accessible :councilemail, :name, :counciltel    has_many   :council_history    has_many   :properties, :through => :council_history, :foreign_key => :property_id end 

council history model -- join table

class councilhistory < activerecord::base   attr_accessible :council_id, :property_id, :vacant     belongs_to :council    belongs_to :property  end 

*view *

<%= simple_form_for @property, :url => url_for(:action => 'update', :controller =>    'properties/build'), :method => 'put' |f| %>   <%= f.simple_fields_for :council |builder| %>       <%= builder.input :council_id, :collection => council.all  %>       <%= builder.submit %>     <% end %> <% end %> 

property/build controller

class properties::buildcontroller < applicationcontroller   include wicked::wizard     steps :tenant, :meter, :council, :confirmed     def show     @property = property.find(params[:property_id])     @tenants = @property.tenants.new(params[:tenant_id])     @meter = @property.build_meter     @council = @property.build_council     @council_history = @property.council_history.build     render_wizard   end    def edit     @property = property.find(params[:property_id])   end     def update     @property = property.find(params[:property_id])     params[:property][:status] = step.to_s     params[:property][:status] = 'active' if step == steps.last     @property.update_attributes(params[:property])     render_wizard @property   end 

in property.rb

add accepts_nested_attributes_for :council_history

class property < activerecord::base  attr_accessible  :name, :address_attributes, :tenants_attributes, :meter_attributes,         :council_history, :council_history_attributes, :property_id, :council_id, :status  belongs_to :user    has_one :council_history    has_one :council, through: :council_history, :foreign_key => :council_id   accepts_nested_attributes_for :council    accepts_nested_attributes_for :council_history #add line   end 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -