Redirecting in Ruby on Rails

5

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
source

2 answers

1

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
source
0

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