Hi Everyone,
Am new to this Ruby on Rails forum & also developing
applications in ROR. I have been stuck up for quite a long time in
‘Authentication’ page. I have developed a basic login authentication
page - which gets user id and password and validates it. No encryption
in password.
Database name : cms
Table name : users
Authentication Code :
class CmsController < ApplicationController
def index
end
def world
render :text => “hello world! The time is #{Time.now}.”
end
Login Authentication
def authenticate
user = User.find_by_email_and_password params[:loginTxt],
params[:pwdTxt]
if user
session[:user_id] = user.id
# ToDo: Store user details in a hash in the session state
session[:first_name] = user.first_name
session[:last_name] = user.last_name
redirect_to(:controller => ‘world’)
else
flash[:error] = ‘Log In Failed’
redirect_to :action => ‘index’
return
end
end
end
I get this error : “NameError in CmsController#authenticate”
“uninitialized constant User”
Can anyone help me solve this problem?? Thanks in advance…