I'm trying to use the authenticate method and rails returns NoMethodError: undefined method 'authenticate' for #.
My controller: class SessionsController < ApplicationController #include SessionsHelper
def login
render 'admin/login'
end
def create
user = User.where(:email => params[:session][:email].downcase).first
if user && user.authenticate(params[:session][:password])
#log_in user
redirect_to :controller => 'admin', :action => 'index'
else
flash[:danger] = "Email ou senha inválido"
render 'login'
end
end
end
I tried to do the rails console also and it returns the same error. When trying to list the object's methods by the console it returns an entire disorganized list "user.methods?" I can not find my error.