If not, is there a gem I can install that lets me do something like:
<%=h link_to "Back", previous_path %>
???
If not, is there a gem I can install that lets me do something like:
<%=h link_to "Back", previous_path %>
???
Could you use the built in :back facility?
link_to "Back", :back
This will link to the referring page, or to the browser's 'back' action. See the docs.
:back works remarkably well for cancels and back buttons.
For redirecting them after a submission I needed to set a session variable.
I do something like this for my feedback form (which can be accessed from any page):
def new
session[:referrer] = request.env["HTTP_REFERER"]
end
def create
# blah blah, create actions
redirect_to session[:referrer]
end
Can you do that with back?
/ JP