How to get authenticate to work?

In my SessionController, I tried to authenticate the user but it’s
failing to authenticate even though I output the information and it’s
all correct.I’m following this tutorial:

Below is my code:

def create
user = User.find_by(email: params[:email].downcase)
if user && user.authenticate(params[:password])
session[:user_id] =
flash[:notice] = “Welcome back, #{}!”
redirect_to user
else[:alert] = “Invalid email/password combination!
#{}, #{}, #{params[:password]}”
render :new
def destroy
session[:user_id] = nil
redirect_to :new

The authenticate works fine in rails console but not when the rails
server. The problem is with this line
user.authenticate(params[:password]) of code.

Any help is much appreciated.

To authenticate the Google Maps JavaScript API using an API key, click
the button below, which takes you to the Google API Console and guides
you through the process of getting a Browser key. Alternatively, follow
these steps to get an API key: Go to the Google API Console.
Analytics Training