0

我正在构建一个 Rails 3 应用程序并尝试安装acts_as_commentable

这是我所做的: 添加到我的 Gemfile 中:

gem "acts_as_commentable"

跑捆绑安装

使用 comments.rb 生成了一个迁移(评论表已正确创建)

然后我想启用我的图书控制器进行评论,所以我添加到 books_controller.rb

acts_as_commentable

但是现在我在加载 /books 时出现错误:

Routing Error

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

建议?

4

1 回答 1

3

act_as_commentable仅在模型中定义。所以你需要在你的模型中定义,而不是你的控制器。

于 2010-09-21T15:49:59.513 回答