Ruby on rails 如何将bundler(0.9.1.pre1)与Rails和CouchRest一起使用
我想使用当前版本的(从0.8到0.9已经有相当多的变化)来管理我的Rails应用程序的精华。首先,我在app文件夹的根目录中创建了一个Ruby on rails 如何将bundler(0.9.1.pre1)与Rails和CouchRest一起使用,ruby-on-rails,ruby,couchdb,bundler,Ruby On Rails,Ruby,Couchdb,Bundler,我想使用当前版本的(从0.8到0.9已经有相当多的变化)来管理我的Rails应用程序的精华。首先,我在app文件夹的根目录中创建了一个Gemfile,并将所有需要的gem添加到其中。然后我(按照手册中的建议)将以下代码放入我的config/environment.rb: begin # Require the preresolved locked set of gems. require File.expand_path('../.bundle/environment', __FILE_
Gemfile
,并将所有需要的gem添加到其中。然后我(按照手册中的建议)将以下代码放入我的config/environment.rb
:
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安装
似乎工作正常,因为您的bundle已经完成了代码>。但启动我的应用程序时,出现以下错误:
$ 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
这里出了什么问题?arrg,刚刚按下发送按钮,有了解决问题的想法。bundler手册说:“[…]在代码的开头包括以下内容。”对于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
你的文件中有什么?谢谢你的提示,达米恩。没错,我也应该提供这些信息。幸运的是我发现了错误。谢谢你发布这个。上周我试图让它工作,但完全失败了。不过,我把bundler初始化代码放在Rails初始化器之前。最后我切换回bundler 0.8.1,Rails 2.3.5(现在)对它有更好的文档记录。很高兴这对您也有帮助。目前,大多数文档都是针对0.9之前的版本的,并且有很多变化。希望这种情况很快会改变。您现在应该接受您的答案,这样就不会出现在未答复的列表中:)感谢您的提示,但是stackoverflow会在2天内阻止您接受自己的答案。现在有可能了。