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....
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi there, Vasanthakumar Csk a écrit :> > 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 : > > > > [snip] > > > > 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 ? :) If not try this: script/generate model User Hope it helps, -- ,= ,-_-. =. Loïc Guitaut ((_/)o o(\_)) http://www.belfalas.org `-''(. .)`-'' Jabber ID : Flink-z1Ll2v8wZ5tg9hUCZPvPmw@public.gmane.org \_/ GnuPG KeyID : 0xA78CD85D
Hi Loïc Guitaut,
Thanks for ur help. Now it is working.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---