I am a complete noob, working with Michael Hartle's (awesome) Rails manual, and have a friendly redirect problem in Ch.10.2.3. The goal is to try to save the location, redirect to the page with the signature, and then redirect back to the original destination when registration is complete. My problem is that it just displays the standard user profile page after logging in / creating a session, not a redirect.
I have this in session_controller:
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination."
@title = "Sign in"
render 'new'
else
sign_in user
redirect_back_or user
end
end
And this is in session_helper:
def authenticate
deny_access unless signed_in?
end
def deny_access
store_location
redirect_to signin_path, :notice => "Please sign in to access this page."
end
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
clear_return_to
end
private
def store_location
session[:return_to] = request.fullpath
end
def clear_return_to
session[:return_to] = nil
end
I'm sure I made a stupid, simple mistake again, but I can't find it .. help?
source
share