免责声明:我是Ruby on Rails的新手。尝试谷歌搜索和搜索StackOverflow没有成功。
我正在创建我的第一个Ruby on Rails应用程序,并希望利用类似于vote_fu和acts_as_voteable的“thumbs_up”插件,并在Rails 3下工作。 https://github.com/brady8/thumbs_up
我已按照上面页面上的安装说明操作,当我运行“gem list”时,我看到了thumb_up插件的安装。
我试图将“acts_as_voteable”mixin添加到如下所示的模型中:
class Foo < ActiveRecord::Base
validates :title, :presence => true
validates :description, :presence => true
acts_as_voteable
end
当我尝试浏览我的应用时,收到以下错误:
未定义的局部变量或方法`acts_as_voteable'用于#
堆栈跟踪对我来说看起来没什么用处:
activerecord(3.0.0) LIB / active_record / base.rb:1016:在
method_missing' app/models/foo.rb:7 activesupport (3.0.0) lib/active_support/dependencies.rb:454:in
加载'activesupport(3.0.0) LIB / active_support / dependencies.rb:454:在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:在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:在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:在each' activesupport (3.0.0) lib/active_support/dependencies.rb:181:in
const_missing'activesupport(3.0.0) LIB / active_support / dependencies.rb:503:在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:在each' activesupport (3.0.0) lib/active_support/dependencies.rb:181:in
const_missing” 应用程序/控制器/ foos_controller.rb:5:在 `索引'
有什么想法吗?我似乎无法在解决这个问题上取得任何进展。
谢谢你, -Rob
答案 0 :(得分:0)
尝试添加初始化文件
# config/initializer/thumbs_up.rb
require 'thumbs_up'
或者你可以从你的模特中要求它
# app/models/foo.rb
require 'thumbs_up'