Redirecting in Ruby on Rails


I am new to Ruby on Rails and would like to know how I can do to redirect from the% share% action to the% share%.

I would like the page "show.html.erb" to be displayed after saving the article created from the page "new.html.erb" .

asked by erickson 08.11.2016 в 01:52

2 answers


To redirect when you finish a create to show you have to use:

redirect_to action: :show

or it would also work in your case:

redirect_to flight_path(@flight)
answered by 09.11.2016 / 02:51

When you need to redirect to show of an object, you can also do it directly:

redirect_to @flight

Y You can also add a message:

redirect_to @flight, notice: "El vuelo se guardó correctamente."
answered by 11.11.2017 в 22:32