Nicely done! You can now update a destination’s name and description. How does it work?
When you visit
http://localhost:8000/destinations/1/edit to edit a destination, it triggers the first turn of the request/response cycle:
- The browser makes a HTTP GET request for the URL
- The Rails router maps this URL to the Destinations controller’s
editaction finds the destination with id 1, stores it in
@destination, and passes it on to the view app/views/destinations/edit.html.erb.
- In the view,
form_forcreates a form with the fields of the
Then when you fill out the form and submit it, it triggers the second turn of the request/response cycle:
- The browser sends the data to the Rails app via an HTTP POST request to the URL
- This time, the Rails router maps this URL to the
destination_paramsmethod to safely collect data from the form. It finds the destination in the database, updates its attributes, and redirects to the destination’s
Click Next to continue.
Sign up to start coding