# Redirect to the url after login

**URL:** <https://www.ruby-forum.com/t/redirect-to-the-url-after-login/184844>\
**Category:** Rails\
**Created:** [March 9, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/redirect-to-the-url-after-login/184844 "2010-03-09T13:39:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [March 9, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/redirect-to-the-url-after-login/184844/1 "2010-03-09T13:39:54Z")

</div>

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 G.

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [March 9, 2010, 6:28pm UTC](https://www.ruby-forum.com/t/redirect-to-the-url-after-login/184844/2 "2010-03-09T18:28:14Z")

</div>

Tushar G. 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 G.

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

[Ethilien :: Better Redirects in Rails](http://ethilien.net/archives/better-redirects-in-rails/) is one such  
resource.
