Hi I have an action which saves the originating resource from which it was called, and returns to it later. This is done by setting: session[:return_to] = request.referer ... redirect_to(session[:return_to]) Which works great for GET resources. The problem is that POST variables aren''t kept in request.referer, so this method fails when the originating resource is a a POST. What''s a good way do the above for POST resources? -- -Alder
Nicolas Cavigneaux
2006-Jun-28 08:59 UTC
[Rails] Re: Saving and reproducing a POST request.
Le mercredi 28 juin 2006 10:11, Alder Green a ?crit?:> HiHello> I have an action which saves the originating resource from which it > was called, and returns to it later. This is done by setting: > > session[:return_to] = request.referer > ... > redirect_to(session[:return_to]) > > Which works great for GET resources. The problem is that POST > variables aren''t kept in request.referer, so this method fails when > the originating resource is a a POST. > > What''s a good way do the above for POST resources?You can maybe use redirect_to(:back) -- Nicolas Cavigneaux http://www.bounga.org http://www.cavigneaux.net -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060628/d8e50f0a/attachment.bin
On 6/28/06, Nicolas Cavigneaux <nico@bounga.org> wrote:> Le mercredi 28 juin 2006 10:11, Alder Green a ?crit: > > Hi > > Hello > > > I have an action which saves the originating resource from which it > > was called, and returns to it later. This is done by setting: > > > > session[:return_to] = request.referer > > ... > > redirect_to(session[:return_to]) > > > > Which works great for GET resources. The problem is that POST > > variables aren''t kept in request.referer, so this method fails when > > the originating resource is a a POST. > > > > What''s a good way do the above for POST resources? > > You can maybe use redirect_to(:back)No, since redirect_to(:back) is merely short-hand for redirect_to(request.env["HTTP_REFERER"]). So it will recreate only GET requests, not POST as I need. Frankly, I''m somewhat surprised there''s no reasonable way to do it in Rails. It''s a pretty common pattern.> -- > Nicolas Cavigneaux > http://www.bounga.org > http://www.cavigneaux.net > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-- -Alder