更新rails 4中的属性?

时间:2013-12-18 12:35:55

标签: ruby-on-rails-4 rails-activerecord

升级到rails 4后,update_attributes不再有效。它说

ArgumentError (argument out of range):

代码:

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"}}

1 个答案:

答案 0 :(得分:1)

这是因为Rails 4使用strong_parameters检查params是否包含安全数据。