I am currently using Postman to make a POST request to the following route: 'localhost:3000/members/login'. The content of the post request is as follows:
{
"email": "[email protected]",
"password": "password"
}
The route is defined as follows:
def login
puts params.inspect
puts member_params.to_s
member = Member.find_by(email: params[:email].to_s.downcase)
end
...
def member_params
params.require(:member).permit(:email, :password, :password_confirmation)
end
and the output that I receive at the console is as follows:
Started POST "/members/login" for 127.0.0.1 at 2018-01-02 18:56:28 -0800
(2.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by MembersController#login as */*
<ActionController::Parameters {"controller"=>"members", "action"=>"login"} permitted: false>
Completed 400 Bad Request in 1ms (ActiveRecord: 0.0ms)
ActionController::ParameterMissing (param is missing or the value is empty: member):
app/controllers/members_controller.rb:94:in `member_params'
app/controllers/members_controller.rb:65:in `login'
As you may have guessed, I am rather new to this. What I am specifically looking for is the following:
1) Is there a quick fix as to why the parameters (email and password) are not being passed into the API from the Postman POST request to help me get this working and
2) To make the answer more generally helpful to future people who might google this question, is there a quick checklist of recommended steps to take when an API call (specifically POST request) does not pass in parameters as intended?
params.require(:member).permittoparams.permitas you are not sending the params nested inmemberkey. - Jagdeep Singh