In this episode, we're adding the ability for users to unfriend each other on our app! The process is pretty easy because we already have most of the backend logic in place thanks to our existing controller.
First, we jump to the friends index page and hook up the 'unfriend' feature. You'll see that unfriending someone works very similarly to cancelling or rejecting a friend request. We're even reusing the same form for both actions, keeping things simple and DRY (don't repeat yourself). While you could separate these with different controllers for more custom behavior, we're opting for the streamlined route to keep our codebase cleaner.
After hooking everything up, we test it out: if you want to unfriend someone like Tabby, it's just a click away. And as a bonus, the person you unfriend can do the same to you, immediately updating both users' friend lists. By the end of this video, you'll have a fully working unfriend feature—no one is stuck being friends if they don't want to be!