undefined local variable or method `acts_as_taggable' in gem
Asked Answered
A

3

13

I'm working on converting a plugin to a gem. In one of the models I'm using acts_as_taggable_on, and it looks like this

class BlogPost < ActiveRecord::Base
  acts_as_taggable
  ....
end

However, I get this error when I run it:

 undefined local variable or method `acts_as_taggable' for #<Class:0x000000060799b8>

and the stack trace looks like this:

activerecord (3.1.0) lib/active_record/base.rb:1082:in `method_missing'
test_gem (0.1.0) app/models/blog_post.rb:28:in `<class:BlogPost>'
test_gem (0.1.0) app/models/blog_post.rb:2:in `<top (required)>'

The acts_as_taggable gem is included in my gemspec file and is installed on the system.

gem install acts-as-taggable-on
Successfully installed acts-as-taggable-on-2.1.1
1 gem installed
Installing ri documentation for acts-as-taggable-on-2.1.1...
Installing RDoc documentation for acts-as-taggable-on-2.1.1...

I have no idea what could be wrong - please help me out

Awful answered 26/9, 2011 at 16:25 Comment(1)
Did you ever find the solution to this? I'm running in the same issue?Russ
S
23

I had the same issue. I restarted my server and it worked fine after

Supererogation answered 3/4, 2012 at 11:16 Comment(1)
I'd to restart rails console. reload! method didn't worked.Operculum
H
4

none of above answers works for me, what I did was put :

 require 'acts-as-taggable-on'

in the beginning the model where I'm using the gem :)

Headgear answered 29/5, 2013 at 14:32 Comment(0)
I
3

Have you put the following in you Gemfile:

gem 'acts-as-taggable-on', '~>2.1.0'

then

bundle install
Ilan answered 1/10, 2011 at 17:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.