Reputation: 58
I'm following the Michael Hartl tutorial and I found a problem and don't know how solved it... my problem is around here whitout ajax.
when I try to do follow to other user I got this:
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/follows_controller.rb:4:in `create'
here is my "follows" controller eq to relationships
before_filter :authenticate_user!
def create
@user = User.find(params[:follows][:followed_id])
current_user.follow!(@user)
redirect_to @user
end
def destroy
@user = Follow.find(params[:id]).followed
current_user.unfollow!(@user)
redirect_to @user
end
the rest (models,rspec) I have the same if you need more code tell me, thanks
Upvotes: 0
Views: 292
Reputation: 9700
Chances are that params[:follows]
is nil. Check what parameters you're submitting to the create
action.
Upvotes: 1