Error Login Rails 3 "NameError in SessionsController#create "
===

Im trying make a sample login whit has_secure_password the gem file is added  but this error persists

undefined local variable or method `password_digest' for #<User:0x23129a0>
app/controllers/sessions_controller.rb:8:in `create'

whit this code

sessions_controller.rb

the line 8 is this 

if user and user.authenticate(params[:password])

---------------------------------------

class SessionsController < ApplicationController
  def new
    
  end
  
  def create
    user = User.find_by_name(params[:name])
    if user and user.authenticate(params[:password])
      session[:user_id] = user.id
      redirect_to admin_url , notice: "Login efetuado com sucesso."
     else
       flash[:notice] = 'Usuario ou senha errados'
       redirect_to login_url
    end
  end
  
  def destroy
    session[:user_id] = nil
    redirect_to login_url, notice: "Logout Efetuado com sucesso."
  end
end

