views:

110

answers:

1

Hi

I'm following a tutorial: http://visionmasterdesigns.com/tutorial-create-a-login-system-in-ruby-on-rails/ to create a login page

when I try to do this part:

def authenticate
02.        #User.new(params[:userform]) will create a new object of User, retrieve values from the form and store it variable @user.
03.        @user = User.new(params[:userform])
04.        #find records with username,password
05.        valid_user = User.find(:first,:conditions => ["user_name = ? and password = ?",@user.user_name, @user.password])
06. 
07.        #if statement checks whether valid_user exists or not
08.        if valid_user
09.        #creates a session with username
10.            session[:user_id]=valid_user.user_name
11.        #redirects the user to our private page.
12.            redirect_to :action => 'private'
13.        else
14.            flash[:notice] = "Invalid User/Password"
15.            redirect_to :action=> 'login'
16.        end
17.end

and run it with a correct username and login, it tells me that

ActiveRecord::RecordNotFound in UsersController#private

Couldn't find User with ID=private

I want it to redirect to the private.html.erb page not search for it!

Thanks for any help

+2  A: 

I think you want render :action => 'private' instead of a redirect.

Andy Gaskell
THANK YOU SO MUCH! VERY VERY MUCH APPRECIATED!
Lily