kannathasan
kannathasan

Reputation: 573

update attributes in rails 4?

After upgrading to rails 4 update_attributes is not working anymore. Its says

ArgumentError (argument out of range):

The code:

def terms_build_methods
  if @lease.blank?
    @lease = params[:current_lease_id].present? ? Lease.find_by_id(params[:current_lease_id].to_i) : Lease.create(params[:lease])
  else
    @lease.update_attributes(params[:lease])
  end
end


params[:lease]:

{"lease"=>{"property_lease_suite_attributes"=>{"tenant_attributes"=>{"tenant_legal_name"=>"OPTICACCESS LLC", "lease_contact_attributes"=>{"name"=>"dhhh", "email"=>"", "address"=>"abc", "phone"=>"hdfdf", "fax"=>"abc"}, "dba_name"=>"abc", "tax_id"=>"fdfdf", "landlord_attributes"=>{"landlord_legal_name"=>"", "name"=>"", "dba_name"=>"", "email"=>"", "address"=>"", "phone"=>"", "fax"=>"", "tax_id"=>""}, "billing_contact_name"=>"", "billing_contact_address"=>"", "notice_contact_name"=>"", "notice_contact_address"=>"", "sublease_or_assignee_contact_name"=>"", "sublease_or_assignee_contact_address"=>"", "note_attributes"=>{"content"=>""}, "info_attributes"=>{"info_type"=>"rrrrrrrr", "renewal"=>"Renewal", "id"=>"1440"}, "id"=>"8025"}, "id"=>"9128"}, "execution"=>"MM/DD/YYYY", "mtm"=>"false", "commencement"=>"05/01/2013", "rent_commencement"=>"MM/DD/YYYY", "expiration"=>"04/30/2018", "note_attributes"=>{"content"=>""}, "real_estate_property_id"=>"1452", "is_executed"=>"true", "is_archived"=>"false", "user_id"=>"61", "is_detailed_view"=>"true"}}

Upvotes: 0

Views: 313

Answers (1)

Hauleth
Hauleth

Reputation: 23586

It's because Rails 4 use strong_parameters to check if params contain safe data.

Upvotes: 1

Related Questions