未定义的局部变量或方法“acts_as_voteable”为了

发布于 2024-10-02 15:03:17 字数 1959 浏览 0 评论 0原文

免责声明:我是 Ruby on Rails 新手。尝试谷歌搜索和 StackOverflow 搜索但没有成功。

我正在创建我的第一个 Ruby on Rails 应用程序,并希望利用“thumbs_up”插件,该插件类似于 vote_fu 和acts_as_voteable,并且在 Rails 3 下工作。 https://github.com/brady8/thumbs_up

我已按照上面页面上的安装说明进行操作,当我运行“gem list”我看到thumbs_up插件已安装。

我尝试将“acts_as_voteable”混合添加到如下所示的模型中:

class Foo < ActiveRecord::Base

  validates :title,       :presence => true
  validates :description, :presence => true

  acts_as_voteable
end

当我尝试浏览我的应用程序时,我收到以下错误:

未定义的局部变量或方法`acts_as_voteable' for #

堆栈跟踪对我来说看起来不太有用:

活动记录 (3.0.0) lib/active_record/base.rb:1016:in method_missing'app/models/foo.rb:7 主动支持 (3.0.0) lib/active_support/dependency.rb:454:in 加载'activesupport(3.0.0) lib/active_support/dependency.rb:454:in load_file' activesupport (3.0.0) lib/active_support/dependency.rb:591:innew_constants_in' activesupport (3.0.0) lib/active_support/dependency.rb:453:in load_file' activesupport (3.0.0) lib/active_support/dependency.rb:340:inrequire_or_load'activesupport (3.0.0) lib/active_support/dependency.rb:491:in load_missing_constant' activesupport (3.0.0) lib/active_support/dependency.rb:183:inconst_missing'activesupport(3.0.0) lib/active_support/dependency.rb:181:in 每个'activesupport (3.0.0) lib/active_support/dependency.rb:181:inconst_missing'activesupport(3.0.0) lib/active_support/dependency.rb:503:in load_missing_constant' activesupport (3.0.0) lib/active_support/dependency.rb:183:in const_missing'activesupport(3.0.0) lib/active_support/dependency.rb:181:in 每个'activesupport (3.0.0) lib/active_support/dependency.rb:181:inconst_missing' 应用程序/控制器/foos_controller.rb:5:in “索引”

有什么想法吗?我似乎无法在解决这个问题上取得任何进展。

谢谢你, -抢

Disclaimer: I'm a Ruby on Rails newbie. Tried Googling and searching StackOverflow without success.

I am creating my first Ruby on Rails app and would like to take advantage of the "thumbs_up" plugin which is similar to vote_fu and acts_as_voteable and works under Rails 3.
https://github.com/brady8/thumbs_up

I have followed the installation instructions on the page above and when I run "gem list" I see the thumbs_up plugin is installed.

I have attempted to add the "acts_as_voteable" mixin to a model which looks like this:

class Foo < ActiveRecord::Base

  validates :title,       :presence => true
  validates :description, :presence => true

  acts_as_voteable
end

When I try to browse my app I receive the following error:

undefined local variable or method `acts_as_voteable' for #

The stacktrace does not look very useful to me:

activerecord (3.0.0)
lib/active_record/base.rb:1016:in
method_missing' app/models/foo.rb:7
activesupport (3.0.0)
lib/active_support/dependencies.rb:454:in
load' activesupport (3.0.0)
lib/active_support/dependencies.rb:454:in
load_file' activesupport (3.0.0)
lib/active_support/dependencies.rb:591:in
new_constants_in' activesupport
(3.0.0)
lib/active_support/dependencies.rb:453:in
load_file' activesupport (3.0.0)
lib/active_support/dependencies.rb:340:in
require_or_load' activesupport
(3.0.0)
lib/active_support/dependencies.rb:491:in
load_missing_constant' activesupport
(3.0.0)
lib/active_support/dependencies.rb:183:in
const_missing' activesupport (3.0.0)
lib/active_support/dependencies.rb:181:in
each' activesupport (3.0.0)
lib/active_support/dependencies.rb:181:in
const_missing' activesupport (3.0.0)
lib/active_support/dependencies.rb:503:in
load_missing_constant' activesupport
(3.0.0)
lib/active_support/dependencies.rb:183:in
const_missing' activesupport (3.0.0)
lib/active_support/dependencies.rb:181:in
each' activesupport (3.0.0)
lib/active_support/dependencies.rb:181:in
const_missing'
app/controllers/foos_controller.rb:5:in
`index'

Any ideas? I can't seem to make any progress on resolving this.

Thank you,
-Rob

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贩梦商人 2024-10-09 15:03:17

尝试添加一个初始化文件

# config/initializer/thumbs_up.rb
require 'thumbs_up'

或者您可以只从您的模型中需要它

# app/models/foo.rb
require 'thumbs_up'

Try adding an initializer file

# config/initializer/thumbs_up.rb
require 'thumbs_up'

Or you could just require it from your model

# app/models/foo.rb
require 'thumbs_up'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文