Reputation: 4004
I have this method in my videos controller:
def notifications
erase_notification_count
end
It calls the erase_notification_count
method defined in my user model:
def erase_notification_count
new_notification_count += (self.notifications.count * (-1))
end
This is the error I get:
NameError in VideosController#notifications
undefined local variable or method `erase_notification_count' for #<VideosController:0x102f0fed0>
Why am I getting this error? How do I fix it?
Upvotes: 1
Views: 1248
Reputation: 4579
You defined the erase_notification_count
on the User model, this means you must call it on a User object. You're trying to call it directly on the VideosController object.
Upvotes: 5