Redirect to the url after login

Hi, I am using authlogic as a authentication mechanism. I am sending out an email to user if he has any new friend request. I am giving a URL in the email from which he can accept the invitation. My problem is whenever the user is not logged in he is redirected to the login page first. After successful login he should be redirected to "accept_friendship" URL But it doesn't it goes to the default page after successful login.

How should I fix this?

Thanks, Tushar Gandhi

Tushar Gandhi wrote:

Hi, I am using authlogic as a authentication mechanism. I am sending out an email to user if he has any new friend request. I am giving a URL in the email from which he can accept the invitation. My problem is whenever the user is not logged in he is redirected to the login page first. After successful login he should be redirected to "accept_friendship" URL But it doesn't it goes to the default page after successful login.

How should I fix this?

Thanks, Tushar Gandhi

There should be lots of rails tutorials out there that speak about remembering the original request URL for redirecting after a successful login.

http://ethilien.net/archives/better-redirects-in-rails/ is one such resource.