Search code examples
ruby-on-railsruby-on-rails-3acts-as-commentable

Rails 3 acts_as_commentable Error: undefined local variable or method `acts_as_commentable'


I'm building a Rails 3 app and am trying to install acts_as_commentable

Here's what I did: Added to my Gemfile:

gem "acts_as_commentable"

Ran bundle install

Generated a Migration with the comments.rb (Comments table was created correctly)

I then wanted to enable my book controller for commenting, so I added to books_controller.rb

acts_as_commentable

But now I get an error when I load /books:

Routing Error

undefined local variable or method `acts_as_commentable' for BooksController:Class

Suggestions?


Solution

  • The act_as_commentable is only define in Model. So you need define in your model, not your controller.