0

バックボーンを使用してクライアント側からモデルを更新し、サーバー側で二重のパラメーターを取得しています。

{"_id"=>"5209df7c2e21a971fd000002",
 "name"=>"Gary Miller",
 "email"=>"gary.miller@att.net",
 "last_login"=>"2013-03-18T20:37:53+00:00",
 "timezone"=>"Central Time (US & Canada)",
 "mobile"=>nil,
 "address"=>nil,
 "address_attributes"=>{},
 "action"=>"update",
 "controller"=>"users",
 "id"=>"5209df7c2e21a971fd000002",
 "user"=>
  {"_id"=>"5209df7c2e21a971fd000002",
   "email"=>"gary.miller@att.net",
   "name"=>"Gary Miller",
   "last_login"=>"2013-03-18T20:37:53+00:00",
   "timezone"=>"Central Time (US & Canada)",
   "mobile"=>nil}}

クライアント側のネットワーク インスペクターでペイロードを調べたところ、クライアントが送信しているデータは次のとおりです。

_id: "5209df7c2e21a971fd000002"
address: null
address_attributes: {}
email: "gary.miller@att.net"
last_login: "2013-03-18T20:37:53+00:00"
mobile: null
name: "Gary Miller"
timezone: "Central Time (US & Canada)"

二重のパラメータが気になります。したがって、解決するためのアイデアは大歓迎です。

4

2 に答える 2

0

これは、config/initializers/wrap_parameters.rb にあるものが原因で発生しています。

ActiveSupport.on_load(:action_controller) do
  wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end

http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.htmlに関する詳細情報

于 2014-07-23T18:07:42.477 に答える