Hello everyone,
I get an error when I click the follow button and I can’t figure out how to fix it.
NoMethodError in FollowingRelationshipsController#create
undefined method `name' for nil:NilClass
app/controllers/following_relationships_controller.rb:4:in `create'
```
```ruby
# following_relationships_controller.rb
def create
user = User.find(params[:user_id])
current_user.followed_users << user # This is line 4
redirect_to user
end
```
I didn't set any methods named name. The only place I found a reference to something called name was in the schema when the index where created for the following_relationships table.
```ruby
add_index "following_relationships", ["followed_user_id"], :name => "index_following_relationships_on_followed_user_id"
add_index "following_relationships", ["follower_id"], :name => "index_following_relationships_on_follower_id"
```
How should I approach this issue?
Thank you for your help.