Rails redirect issue - Hartl's Rails Tutorial 10.2.3 -
i'm complete noob working through michael hartl's (awesome) rails tutorials, , have issue friendly redirect in ch.10.2.3. purpose try store location, redirect sign in page, redirect original intended destination when sign-in complete. problem renders standard user profile page after signing in/creating session, rather redirecting.
i have in sessions_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 in sessions_helper:
def authenticate deny_access unless signed_in? end def deny_access store_location redirect_to signin_path, :notice => "please sign in access 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've yet again made stupid, simple mistake can't find it.. help?
the code available here: https://github.com/railstutorial
consider making new git branch (or new project) uses repository's code. have working local version comparison when things go wrong.
Comments
Post a Comment