NameError in CmsController#authenticate

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

def world
render :text => “hello world! The time is #{}.”

Login Authentication

def authenticate
user = User.find_by_email_and_password params[:loginTxt],
if user
session[: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’)
flash[:error] = ‘Log In Failed’
redirect_to :action => ‘index’


I get this error : “NameError in CmsController#authenticate”
“uninitialized constant User”

Can anyone help me solve this problem?? Thanks in advance…

Hi there,

Vasanthakumar C. a écrit :

I get this error : “NameError in CmsController#authenticate”
“uninitialized constant User”

Hmm it may be sound as a silly question, but are you sure to have a
model named User ? :slight_smile:
If not try this: script/generate model User

Hope it helps,

Hi Loïc Guitaut,
Thanks for ur help. Now it is working.