# Remembering where you came from

**URL:** <https://www.ruby-forum.com/t/remembering-where-you-came-from/136301>\
**Category:** Rails\
**Created:** [April 30, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/remembering-where-you-came-from/136301 "2008-04-30T16:16:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TrevorD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/779978/32.png) [@TrevorD](https://www.ruby-forum.com/u/TrevorD)\
**Post date:** [April 30, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/remembering-where-you-came-from/136301/1 "2008-04-30T16:16:19Z")

</div>

I’ve done a little searching here and on google, but im not sure i  
even know what to search for. Im trying to figure out how to, after  
adding or editing a record, redirect back to the view i was on.

So, for example, i’m viewing tasks for a specific user, so im at a  
page /users/justin/tasks which routes to a byuser method in  
tasks\_controller with a user param of justin. Seems to work ok. I  
add a new record, and save. Is there an easy way to go back to that  
same view after the save though? I’ve created a session variable  
called lastview (which gets set in my byuser and index methods), and  
redirected to that, but it just feels like there should be an easier  
way to do that.

Can someone point me in the right direction?

Thanks.

Trevor

---

<div class="post-metadata">

**Author:** ![TrevorD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/779978/32.png) [@TrevorD](https://www.ruby-forum.com/u/TrevorD)\
**Post date:** [April 30, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/remembering-where-you-came-from/136301/2 "2008-04-30T17:00:04Z")

</div>

you could pass in the old view as a parameter to the form

---

<div class="post-metadata">

**Author:** ![TrevorD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/779978/32.png) [@TrevorD](https://www.ruby-forum.com/u/TrevorD)\
**Post date:** [April 30, 2008, 7:48pm UTC](https://www.ruby-forum.com/t/remembering-where-you-came-from/136301/3 "2008-04-30T19:48:44Z")

</div>

put following in the form of your tasks view page,

```
<input type=hidden name="original_uri" value="<%=

```

request.request\_uri%\>" /\>

after you are done with adding new record, just:

```
redirect_to params[:original_uri]

```

check out the “Ruby On Rails Blogs Syndication” at  
[www.radio21g.com/myradio/channel/8](http://www.radio21g.com/myradio/channel/8)
