Harry Mattocks
Harry Mattocks

Reputation: 135

Undefined local variable or method `acts_as_votable'

I'm trying to use the acts_as_votable gem in Rails 5.2, using this tutorial.

I've followed all the steps and read the documentation, but for some reason I keep getting a NameError.

This is my Post Model:

class Post < ApplicationRecord
  acts_as_votable

  belongs_to :user

  has_many :comments
  has_many :reactions

  extend FriendlyId
  friendly_id :url, use: :slugged

end

My Gemfile:

gem "acts_as_votable"

Screenshot: Error Page

Any help would be appreciated. Thanks in advance.

Upvotes: 1

Views: 293

Answers (1)

hkly
hkly

Reputation: 325

Have you restarted your server since you've added the gem? You need to restart your rails server whenever you add/remove gems.

Upvotes: 1

Related Questions