Question

I have a ruby on rails api where I want to sign my request data by appending a hashed version of all passed in parameters to the request and rebuild this one at the server side as well to validate the integrity of the requests.

When I simply use the params method in the controller I have different parameters (e.g. for an update-method which is specified by this:

put 'login' => 'login#update'

I get as parameters on the server:

{"timestamp"=>"1399562324118", "secured"=>"xxx", 
 "login"=>{"timestamp"=>"1399562324118", "secured"=>"xxx"}}

although I only send the request from the client with

{"timestamp"=>"1399562324118", "secured"=>"xxx"}

Does any one have an idea how to get rid of this "login" parameter in the params list in a generic way? I do not want to exclude this for every single request of my api.

Thanks a lot!

Was it helpful?

Solution

Per the Rails Edge guide on ActionController:

"If you've turned on config.wrap_parameters in your initializer or calling wrap_parameters in your controller, you can safely omit the root element in the JSON parameter"

See http://guides.rubyonrails.org/action_controller_overview.html#json-parameters

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top