A few readers have also asked me to add an Unfollow button for the sample social network in Rails Crash Course. Here’s how I made that happen:
I created a new branch called unfollow-user and added the Unfollow button.
Here are the steps I followed:
config/routes.rbto include a route for
unfollow_user. Since this removes a row from the database, I used the
app/models/user.rb, similar to the
app/controllers/users_controller.rb, similar to the
Add a Unfollow button to the view at
app/views/users/show.html.erb. I also added some logic to show the correct button.
The changes are in this commit: 29fa67a
Hope this helps!