레일과 소파 레스트와 함께 Bundler (0.9.1.pre1) 사용 방법
-
19-09-2019 - |
문제
현재 버전을 사용하고 싶습니다 번들 (0.8에서 0.9까지의 일부 변화가있었습니다) 내 Rails 앱의 보석을 관리하기 위해. 먼저 나는 a Gemfile
앱 폴더의 루트에 필요한 모든 보석을 추가했습니다. 그런 다음 (매뉴얼에 권장되는대로) 다음 코드를 내 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 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
여기서 무엇이 잘못 되었습니까?
해결책
ARRRG는 방금 보내기 버튼을 누르고 문제를 해결 한 아이디어를 가지고있었습니다. 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
제휴하지 않습니다 StackOverflow