2011-03-30 84 views
0
gem install rubyoverflow 
irb 
> require 'rubyoverflow' 
=> true 

但其他模塊:需要在控制器

require 'rubyoverflow' 
include Rubyoverflow 

class QuestionsController < ApplicationController 
    def question_by_tag 
     ruby_q = Questions.retrieve_by_tag('ruby') 

得到錯誤:

LoadError in QuestionsController#question_by_tag no such file to load -- rubyoverflow

Rails.root: D:/artefacts/dev/projects/stack

app/controllers/questions_controller.rb:1:in `'

This error occurred while loading the following files: rubyoverflow

有控制器要導入爲模的任何特殊規則?

+0

哪個紅寶石你使用和哪個導軌?如果它是一個寶石它可以在你的控制器中自動獲得 – corroded 2011-03-30 08:41:38

回答

2

爲什麼你同時使用requireincludeinclude Rubyoverflow將足以

UPD

創業板,你應該把它添加到您的Gemfile(Rails的3.X)或config/environment.rb(Rails的2.X)

# Gemfile 
gem "rubyoverflow" 
# environment.rb 
config.gem "rubyoverflow" 

然後運行bundle爲Rails 3.x和rake gems:install for Rails 2.x

+0

我在gem頁面上獲得這個代碼https://github.com/phsr/rubyoverflow – demas 2011-03-30 08:44:15

+0

你使用什麼軌道? – fl00r 2011-03-30 08:45:45

+0

感謝Gemfile和bundle。 – demas 2011-03-30 08:52:52