An Edit Route6:24 with Jay McGavren
Now our users can create a new Page. But they'd better get it right the first time, because right now they can't go back and change what they've entered... Maybe we should fix that. Let's give them a form to allow them to update existing Pages.
When a user wants to create a new model object, the browser sends an HTTP GET request to retrieve a blank form. When they submit the new form, the browser sends an HTTP POST request to create a new record on the server.
And when a user wants to edit an existing model object, the browser needs to send an HTTP GET request to retrieve that form as well. The difference is that the edit form will be pre-populated with the existing object's data.
Another difference is that when you're modifying existing data on the server (rather than adding new data), you're supposed to use a PUT or PATCH request rather than a POST request. So when you click the submit button on the edit form, that's what your browser sends to the server: a PATCH request.
You need to sign up for Treehouse in order to download course files.Sign up