2010-02-09 42 views
2

我想使用bundler的當前版本(從0.8到0.9有很多變化)來管理我的Rails應用程序的寶石。首先,我在app文件夾的根目錄下創建了一個Gemfile,並將所有必需的寶石添加到它。然後我把(按照手冊中的推薦)下面的代碼我config/environment.rb如何在Rails和CouchRest中使用bundler(0.9.1.pre1)

begin 
    # Require the preresolved locked set of gems. 
    require File.expand_path('../.bundle/environment', __FILE__) 
rescue LoadError 
    # Fallback on doing the resolve at runtime. 
    require "rubygems" 
    require "bundler" 
    Bundler.setup 
end 

bundle install似乎很好地工作,因爲它與Your bundle is complete!完成。但是當啓動我的應用程序時,出現以下錯誤:

$ ruby script/server 
=> Booting WEBrick 
=> Rails 2.3.5 application starting on http://0.0.0.0:3000 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant CouchRest (NameError) 
     from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing' 
     from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing' 
     from /home/kuf/data/Arbeit/Decodon/2009-05-08-Project_Orange/orangemix/fuse/config/initializers/couchdb.rb:35 
     from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking' 
     from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load' 
     from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in' 
     from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load' 
     from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:622:in `load_application_initializers' 
     ... 11 levels... 
     from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84 
     from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' 
     from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' 
     from script/server:3 

這裏有什麼問題?

+0

這是什麼,你有你'Gemfile'? – 2010-02-09 10:24:45

+0

感謝提示,Damien。誠然,我也應該提供這些信息。幸運的是我發現了錯誤。 – konrad 2010-02-09 10:34:16

回答

1

Arrrg,只是推送發送按鈕,並有一個解決問題的想法。捆綁商手冊說:「[...]在你的代碼的開頭加入以下內容。」對於Rails應用程序,你必須正確地之前把部分提到在config/environment.rb底部得到的一切設置:

RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION 

require File.join(File.dirname(__FILE__), 'boot') 

Rails::Initializer.run do |config| 
... 
end 

# Put the bundler related stuff here! 
begin 
    # Require the preresolved locked set of gems. 
    require File.expand_path('../.bundle/environment', __FILE__) 
rescue LoadError 
    # Fallback on doing the resolve at runtime. 
    require "rubygems" 
    require "bundler" 
    Bundler.setup 
end 
+0

感謝您發佈此信息。上週我試圖讓這個工作徹底失敗。雖然我在Rails初始化器之前放置了初始化代碼。我最終轉而使用捆綁器0.8.1,這在Rails 2.3.5中有更好的文檔記錄(現在)。 – 2010-02-09 20:48:17

+0

很高興這也幫助了你。目前大多數的文檔都是在0.9以前版本,而且很多都改變了。希望這會很快改變。 – konrad 2010-02-10 11:07:01

+0

現在你應該接受你的答案,所以這停止顯示在未答覆的列表.. :) – Trevoke 2010-02-11 19:09:43

相關問題