Hi everyone, i followed colins example and it worked perfectly but now i
get this error
ActionController::DoubleRenderError in UserController#login
Render and/or redirect were called multiple times in this action. Please
note that you may only call render OR redirect, and at most once per
action. Also note that neither redirect nor render terminate execution
of the action, so if you want to exit an action after redirecting, you
need to do something like “redirect_to(…) and return”.
I feel that something is wrong with this code
def login
@title = “Login - Books”
if request.post?
@user = User.new(params[:user])
user = User.find_by_screen_name_and_password(@user.screen_name,
@user.password)
if user
session[:user_id] = user.id
flash[:notice] = “User #{user.screen_name} logged in”
redirect_to :action => “index”
else
# Don’t show the password in the view
@user.password = nil
flash[:notice] = “Invalid email/password combination”
end
end
if session[:user_id]
flash[:notice] = "Already registed and logged in! You cannot view
the register or login!"
redirect_to :action => :index
end
end
///////////////////////////////////////////////////////
if session[:user_id]
flash[:notice] = "Already registed and logged in! You cannot view
the register or login!"
redirect_to :action => :index
end
///////////////////////////////////////////////////////
what this does, is if session ID is found, then it takes the login page
back to index…can someone help me please 