# Global back link

**URL:** <https://www.ruby-forum.com/t/global-back-link/132905>\
**Category:** Rails\
**Created:** [March 25, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/global-back-link/132905 "2008-03-25T18:06:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![veyron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85f322/32.png) [@veyron](https://www.ruby-forum.com/u/veyron)\
**Post date:** [March 25, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/global-back-link/132905/1 "2008-03-25T18:06:11Z")

</div>

One thing I’ve encountered a lot within application development is the  
need for a global “back link”. Yes, I know you can use javascript,  
but I am looking for a more elegant approach… accomplished using  
the rails framework. The scenario is… I can arrive at the same page  
from various origins within my application. But I would like to be  
able to easily redirect the user back the exact page they came  
from … or if an “edit/update” occurred, I could perform the save  
and return the user back appropriately. Has anyone seen/implemented  
such a solution before??

---

<div class="post-metadata">

**Author:** ![veyron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85f322/32.png) [@veyron](https://www.ruby-forum.com/u/veyron)\
**Post date:** [March 25, 2008, 6:29pm UTC](https://www.ruby-forum.com/t/global-back-link/132905/2 "2008-03-25T18:29:49Z")

</div>

On 25 Mar 2008, at 17:05, veyron wrote:

> One thing I’ve encountered a lot within application development is the  
> need for a global “back link”. Yes, I know you can use javascript,  
> but I am looking for a more elegant approach… accomplished using  
> the rails framework. The scenario is… I can arrive at the same page  
> from various origins within my application. But I would like to be  
> able to easily redirect the user back the exact page they came  
> from … or if an “edit/update” occurred, I could perform the save  
> and return the user back appropriately. Has anyone seen/implemented  
> such a solution before??

Well there’s redirect\_to :back (but if the referrer isn’t set that  
won’t work)

Fred

---

<div class="post-metadata">

**Author:** ![veyron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85f322/32.png) [@veyron](https://www.ruby-forum.com/u/veyron)\
**Post date:** [March 25, 2008, 9:57pm UTC](https://www.ruby-forum.com/t/global-back-link/132905/3 "2008-03-25T21:57:07Z")

</div>

Thanks, Fred. That will work for 90% of what I need. The other 10%  
comes from the need to know where the “new/edit” requests came from  
(list page, etc).

On Mar 25, 1:28 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
