Rails duplicated the parameters inside the resource

£可爱£侵袭症+ 提交于 2019-12-03 15:22:55

问题


I am using the Angular Resource and I don't understand why Rails duplicated the parameters and put it inside the resource name. I just need to understand why this is happening.

// post data
{"title":"asdsad"}

// rails parameters 
Parameters: {"title"=>"asdsad", "presentation"=>{"title"=>"asdsad"}}

Duplicate because welcome to Stackoverflow where you need 50 points to comments so this happen. I really so sorry: AngularJS $resource sending out an extra "registration" hash?


回答1:


..if you've turned on config.wrap_parameters in your initializer [check the file config/initializers/wrap_parameters.rb] or [you] are calling wrap_parameters() in your controller...the parameters will be cloned and wrapped in the key according to your controller's name by default.

http://guides.rubyonrails.org/action_controller_overview.html#parameters http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html

In other words, what you are seeing is the default way rails enters things in the params hash.



来源:https://stackoverflow.com/questions/27672954/rails-duplicated-the-parameters-inside-the-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!