Page redirect


In my application, if someone enters url which requires login, am
redirecting to login page if they have not logged in already, after
logging, i want to take the user to page from where he has been
redirected to login page. how it can be done?

example : questions/new -> redirected to login
after logging, redirect user to questions/new

How to do?

Thankx in advance

The solution is simply save requested url in session and after user
in send it back to
the session url.

If you are using restful authentication, you may get the solution,
GitHub - technoweenie/restful-authentication: inactive project.

Redirect to the URI stored by the most recent store_location call


to the passed default. Set an appropriately modified

after_filter :store_location, :only => [:index, :new, :show, :edit]

for any controller you want to be bounce-backable.

def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil

On Wed, Sep 30, 2009 at 2:43 PM, Sharanya S.
[email protected]wrote:

How to do?

Thankx in advance

Posted via

Thanks and Regards
Saurabh P.
skype: sorab_pune
yahoo & gtalk: saurabh.purnaye
msn: [email protected]