2011-11-29 158 views
1

我有一個新的Ruby on Rails安裝,我可以看到默認的開始頁面。我跟着this guide爲了安裝MongoDB到Rails。Ruby on Rails和MongoDB

現在運行rake test當我得到這個錯誤:

**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance. 
    You can install the extension as follows: 
    gem install bson_ext 

    If you continue to receive this message after installing, make sure that the 
    bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version. 

我已經安裝了bson_ext寶石,這意味着現在bson_ext在沒有我的負荷路徑或寶石是不一樣的版本。

負載路徑在哪裏?我該如何改變它? 如何檢查寶石是否是相同的版本?

回答

5

如果您使用的是Ruby on Rails 3+,則應檢查您的Gemfile中是否引用了bson_ext gem。

+0

這不是,我該如何添加它?對不起,但我是Rails的新手。從與PHP的長期關係切換=) – Dimme

+0

好吧,我認爲這解決了它:'gem「bson_ext」'。謝謝! – Dimme

+2

在您的gemfile中添加'gem「bson_ext」'行,然後從命令行運行'bundle update'。 – theTRON

2

打開的Gemfile(在你的Rails應用程序的根目錄),並添加一條線,說:bson_ext

你應該有:

gem mongo 
gem bson_ext 

而且,這裏是從10gen docs在運行測試一些更多的信息導軌:

運行測試 需要稍作修改才能使耙測試工作(感謝John P. Wood)。創建包含以下文件的lib /任務/ mongo.rake:

namespace :db do 
    namespace :test do 
    task :prepare do 
     # Stub out for MongoDB 
    end 
    end 
end 

現在各種耙測試任務將正常運行。查看John的帖子瞭解更多詳情。

他們也參考John Wood's post這是相當不錯的。

+0

您指的是與我的問題中相同的文章。 – Dimme

+0

是的,但我實際上告訴你如何去做。 –