Search code examples
ruby-on-railsangularjsangular-resource

Rails duplicated the parameters inside the resource


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?


Solution

  • ..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.