Here is my code in controller:
def login
@user = params[:user]
render :json => @user
end
And here is my POST data:
{
"user": {
"email":"2",
"password":2
}
}
But I can only retrieve a JSON like:
{
"email": "2",
"password": 2
}
How can I parse JSON by params for both email and password, and use the parameter like
params[:email]
params[:password]
so that i can compare my params to the database. Thanks a lot!
According to what I understood, you need to get the data email and password directly from params[]. This is simply a nested params so you can do
params['user']['email']
params['user']['password']
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