html – Redirecting in Ruby on Rails

Question:

I am new to Ruby on Rails and would like to know how I can redirect from the New action to the Show action.

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

Answer:

To redirect at the end of a create a show you have to use:

redirect_to action: :show

or it would also work in your case:

redirect_to flight_path(@flight)
Scroll to Top