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: "example@gmail.com",
}
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 evenparams['username']since params is aHashWithIndifferentAccess.Note that you can easily inspect the params using the debugger gem, or just slam a
raisein your controller action to see them on the error page when in development mode.