I made a rails application and added the acts-as-taggable-on gem, ran the rake db:migrate and added the field to Article.rb. I seem to get this error with a rail 5.1 app. I can't figure out what it is.
GemFile
gem 'acts-as-taggable-on', '~> 4.0'
Article.rb
class Article < ApplicationRecord
include TheComments::Commentable
acts_as_taggable_on :tags
belongs_to :user
# Denormalization methods
# Check the documentation for information on advanced usage
def commentable_title
title
end
def commentable_url
['', self.class.to_s.tableize, id].join('/')
end
def commentable_state
:published.to_s
end
end
However I get this error:
Running via Spring preloader in process 18395
Loading development environment (Rails 5.1.2)
2.4.0-rc1 :001 > Article
NoMethodError: undefined method `acts_as_taggable_on' for Article (call 'Article.connection' to establish a connection):Class
from app/models/article.rb:6:in `<class:Article>'
from app/models/article.rb:1:in `<top (required)>'
from (irb):1
2.4.0-rc1 :002 > Article
NoMethodError: undefined method `acts_as_taggable_on' for Article (call 'Article.connection' to establish a connection):Class
from app/models/article.rb:6:in `<class:Article>'
from app/models/article.rb:1:in `<top (required)>'
The reason for the issue is with the version of the gem. The version of the gem that you are using doesn't support Rails 5.
You can resolve your error by pulling the gem from direct from the github. For that just use below code in your gemfile:
gem 'acts-as-taggable-on', :git => 'https://github.com/mbleigh/acts-as-taggable-on'