In this episode, we dive into how to update records—specifically posts—in our application. We'll keep things concise since updating is really similar to how we've already handled deleting records in the previous video.
You'll see a quick walkthrough of the update process: First, we talk about authorizing the action to make sure only the right users can make changes. Then, we'll pass in the specific post to update, change some fields (like the title or body), and actually perform the update in the database. You'll notice, just like with delete, there are a couple of ways to find the post to update—either directly or through the user's relationship to the post.
We demo updating a post by changing its body and confirming it's been updated in the database. Finally, we emphasize the importance of adding authorization so nobody can just edit any post by guessing IDs. By the end of this video, you'll see two different methods for updating posts and understand the essential security step of authorization before making any changes.