我安装了一些用于测试的新宝石,并遇到未初始化的常量ActionController :: Dispatcher :: MiddlewareStack错误。我遵循关于gem rdocs的说明 - 在我的environment.rb文件中指定了gem依赖项,然后运行rake gems:install和rake gems:unpack。未初始化的常量ActionController :: Dispatcher :: MiddlewareStack
我还将我的environment.rb文件一次一行地复制到不同的项目中,但没有收到错误消息。我想知道还有哪些事情可能会出错。
以下是错误的一个更长的版本(我第一次跑进运行一个简单的测试误差;同样的事情发生在一个控制台时,我确实需要“active_support”):
$ ruby test/unit/user_test.rb
** has_many_polymorphs: rails environment detected
/Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant ActionController::Dispatcher::MiddlewareStack (NameError)
from /Users/thaiyoshi/.gem/ruby/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:71
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from /Users/thaiyoshi/.gem/ruby/1.8/gems/has_many_polymorphs-2.13/lib/has_many_polymorphs/autoload.rb:2
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
... 8 levels...
from ./test/unit/../test_helper.rb:2:in `require'
from ./test/unit/../test_helper.rb:2
from test/unit/user_test.rb:1:in `require'
from test/unit/user_test.rb:1
这是我的环境。 RB文件(默认情况下删除评论):
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
# config.gem 'has_many_polymorphs', :version => "2.12"
# require ‘has_many_polymorphs‘
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
require 'has_many_polymorphs'
require 'active_support'
Rails::Initializer.run do |config|
config.time_zone = 'UTC'
config.gem "thoughtbot-factory_girl",
:lib => "factory_girl",
:source => "http://gems.github.com"
config.gem 'thoughtbot-shoulda',
:lib => false,
:source => 'http://gems.github.com'
end
我认为它必须处理'has_many_polymorphs'行。我GOOGLE'has_many_polymorphs'与rails 2.3.2的兼容性,但没有发现任何明确的。 – sutee 2009-05-01 09:09:53
您是否尝试过每次安装一颗宝石? 此外,您可能希望创建一个新的秘密,现在您已经与我们所有人分享了它:P。 – allyourcode 2009-05-02 06:31:30