2010-11-15 30 views
1

聲明:我是Ruby on Rails新手。嘗試谷歌搜索和搜索StackOverflow沒有成功。未定義的局部變量或方法`acts_as_voteable'

我on Rails應用程序創建我的第一個Ruby和想採取「thumbs_up」插件,它類似於vote_fu和acts_as_voteable下Rails的作品3. https://github.com/brady8/thumbs_up

我按照安裝說明的優勢在上面的頁面上,當我運行「寶石列表」時,我看到安裝了thumbs_up插件。

我已經嘗試了「acts_as_voteable」混入增加,看起來像這樣一個模型:

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: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'

有什麼想法?我似乎無法在解決此問題方面取得任何進展。

謝謝 -Rob

+0

你添加到您的Gemfile和運行命令行中的「bundle install」? – johnmcaliley 2010-11-15 05:25:07

+0

是的,我確實添加了「gem'thumbs_up'」到我的Gemfile並運行「軟件包安裝」。 – 2010-11-15 05:43:36

回答

0

嘗試增加一個初始化文件

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

或者你可以要求它從你的模型

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

這看起來很有效。在我能確認之前,我必須在我看來做一些額外的工作。謝謝單片眼鏡! – 2010-11-15 05:41:19

相關問題