How to match application / json POST request with parameters in rails?

I am being passed to the json body for a request by mail, but I'm not sure if the best way to display this json body is to request parameters in rails:

{ username: "example-user", password: "password", email: " example@gmail.com ", } 

and in the controller I want to get the parameters ["username"], is this possible? how should i do this?

+7
source share
1 answer

see guides for complete information.

you can simply access params[:username] or even params['username'] since params is a HashWithIndifferentAccess .

Please note that you can easily check the parameters using the debug gem or just block raise in the action of your controller to see them on the error page in development mode.

+6
source

All Articles