我正在使用 Angular 资源,但我不明白为什么 Rails 会重复参数并将其放在资源名称中。我只需要了解为什么会发生这种情况。
// post data
{"title":"asdsad"}
// rails parameters
Parameters: {"title"=>"asdsad", "presentation"=>{"title"=>"asdsad"}}
重复是因为欢迎来到 Stackoverflow,您需要 50 分才能发表评论,这样才会发生这种情况。我真的很抱歉:AngularJS $resource 发送额外的“注册”哈希? https://stackoverflow.com/questions/18442474/angularjs-resource-sending-out-an-extra-registration-hash
..如果您已在初始化程序中打开 config.wrap_parameters [检查文件
config/initializers/wrap_parameters.rb] 或 [you] 正在调用
控制器中的wrap_parameters()...参数将被克隆并
默认情况下,根据控制器的名称包装在密钥中。
http://guides.rubyonrails.org/action_controller_overview.html#parameters http://guides.rubyonrails.org/action_controller_overview.html#parameters
http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html
换句话说,您所看到的是 Rails 在 params 哈希中输入内容的默认方式。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)