user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
with user.authenticate (password) If it matches, the user's information is given. A method that returns false if incorrect.
Mainly used for login etc.
if user && user.authenticate(params[:session][:password])
In this statement, the logical product (and) of && is other than nil and false. In Ruby, all objects other than nil and false use the property that the boolean value is true, and whether or not you can log in is executed using an if statement.
It took a long time to understand because the understanding of the boolean value was shallow. .. ..
Recommended Posts