I am being passed in a json body for a post request, but i'm not sure the best way to map this json body to request params in rails:
{
username: "example-user",
password: "password",
email: "[email protected]",
}
and in the controller i wish to acccess params["username"], is this possible? how should i do it?
see the guides for a comprehensive information.
you can simply access to params[:username]
or even params['username']
since params is a HashWithIndifferentAccess
.
Note that you can easily inspect the params using the debugger gem, or just slam a raise
in your controller action to see them on the error page when in development mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With