toast
toast

Reputation: 592

Acts_as_taggable_on undefined local variable or method

Rails 3.0.3

ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]

acts-as-taggable-on (2.0.6)

i have bundle installed and rake db:migrated

I have the following in my gemfile:

gem 'acts-as-taggable-on'

and i have the following in my items controller

acts_as_taggable

I read the docs here and i have searched stack overflow fairly extensively but i am still getting the error:

ActionController::RoutingError (undefined local variable or method `acts_as_taggable' for ItemsController:Class):

app/controllers/items_controller.rb:2:in <class:ItemsController>' app/controllers/items_controller.rb:1:in'

The only thing that I can see is that possibly i need to 'require' taggable somewhere (but this is not mentioned in the docs) is this likely to be the case? I was under the impression that rails3+ did not require requires... or have i got that wrong?

Upvotes: 1

Views: 1020

Answers (1)

JCorcuera
JCorcuera

Reputation: 6834

The acts_as_taggable goes in your model not in your controller:

class Item < ActiveRecord::Base
    # Alias for <tt>acts_as_taggable_on :tags</tt>:
    acts_as_taggable
end

Hope this helps

Upvotes: 1

Related Questions