Remembering where you came from

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

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

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