Karthikragunath B. wrote:
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.
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
session[‘saved_location’] = request.request_uri
session[‘saved_location’] = nil
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