Does the rails have previous_path / url?

If not, is there a stone I can install that allows me to do something like:

<%=h link_to "Back", previous_path %>

???

+3
source share
2 answers

Could you use the inline: back object?

link_to "Back", :back

This will be a link to the link page or to the browser action "back". See docs .

+10
source

: back works very well for cancel and return buttons.

To redirect them after sending, I needed to set a session variable.

I am doing something similar for my feedback form (which can be accessed from any page):

In the feedback controller

def new
  session[:referrer] = request.env["HTTP_REFERER"]
end

def create
  # blah blah, create actions
  redirect_to session[:referrer]
end

?

/JP

-1

Source: https://habr.com/ru/post/1743900/


All Articles