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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you could pass in the old view as a parameter to the form On Wed, Apr 30, 2008 at 7:54 AM, TrevorD <tdunsford-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
roosevelt.lai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-30 17:31 UTC
Re: Remembering where you came from...
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 On Apr 30, 10:58 pm, "Roger Pack" <rogerpack2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you could pass in the old view as a parameter to the form > > On Wed, Apr 30, 2008 at 7:54 AM, TrevorD <tdunsf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---