Karthikragunath Bhavani
2008-Apr-03 09:37 UTC
somebody help me to get previous page url in RoR
hi all, im having a view page called "edit" and im having a back button in it.im using this edit view page in many place of my application.i want to go back to the page which calls this "edit" page no matter what that page is.so somebody please help me to get the previous page url in ruby on rails.waiting for the response. regards, karthik. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
request.referer might be what you want ^-^ On Apr 3, 5:37 pm, Karthikragunath Bhavani <rails-mailing-l...@andreas- s.net> wrote:> hi all, > im having a view page called "edit" and im having a back button > in it.im using this edit view page in many place of my application.i > want to go back to the page which calls this "edit" page no matter what > that page is.so somebody please help me to get the previous page url in > ruby on rails.waiting for the response. > > regards, > > karthik. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karthikragunath Bhavani wrote:> > hi all, > im having a view page called "edit" and im having a back button > in it.im using this edit view page in many place of my application.i > want to go back to the page which calls this "edit" page no matter what > that page is.so somebody please help me to get the previous page url in > ruby on rails.waiting for the response. > > regards, > > karthik.How i normally do this is to have an application.rb method which saves the current url to the session, and another that redirects to the stored url (which should have a default in case it can''t find it). Then, in pages which i want to bookmark for returning to (you might not want someone to get sent back to some pages), then save the url. EG in application.rb def store_location session[''saved_location''] = request.request_uri end def redirect_to_back_or_default(default) if session[''saved_location''].nil? redirect_to default else redirect_to session[''return-to''] session[''saved_location''] = nil end end Then, in a page that you want the user to be able to go back to: <% store_location %> Then, just call ''redirect_to_back_or_default(''enter your chosen default url here, depending on context'') to send someone back. I think i copied this off someone else a while ago so props if this is your code :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Karthikragunath Bhavani
2008-Apr-03 11:12 UTC
Re: somebody help me to get previous page url in RoR
Thanks williams, its working great.thanks for ur timely help. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---