Rails uninitialised常量ActiveSupport :: Autoload(NameError)?

时间:2014-06-19 10:00:07

标签: ruby-on-rails ruby

我在Michael Hartl教程的第3章,我被困在测试部分。 最初它有一个未初始化的常量Rails(NameError)的问题,但在添加

之后
require 'rspec/rails'
require 'active_support'
require 'active_support/deprecation'
require 'activerecord-nulldb-adapter'

到spec_helper.rb文件,uninitalised常量ActiveSupport :: Autoload(NameError)存在这个新问题。

附件是错误:

C:\Users\HuiHui\MyProject\sampleapp>bundle exec rspec spec/requests/static_pages
_spec.rb
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1.1/lib/action
_view/template.rb:8:in `<class:Template>': uninitialized constant ActiveSupport:
:Autoload (NameError)
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template.rb:7:in `<module:ActionView>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template.rb:5:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template/resolver.rb:4:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template/resolver.rb:4:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/testing/resolvers.rb:1:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/testing/resolvers.rb:1:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails/view_rendering.rb:1:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails/view_rendering.rb:1:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails.rb:4:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails.rb:4:in `<top (required)>'
        from C:/Users/HuiHui/MyProject/sampleapp/spec/spec_helper.rb:17:in `requ
ire'
        from C:/Users/HuiHui/MyProject/sampleapp/spec/spec_helper.rb:17:in `<top
 (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `block in requires='
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `each'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `requires='
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into
'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:100:in `each'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:100:in `process_options_into'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:22:in `configure'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:96:in `setup'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:85:in `run'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:70:in `run'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:38:in `invoke'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/exe/rspec:4:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bin/rspec:23:in `lo
ad'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bin/rspec:23:in `<m
ain>'

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

尝试从

更改订单
require 'rspec/rails'
require 'active_support'
require 'active_support/deprecation'
require 'activerecord-nulldb-adapter'

require 'active_support'
require 'active_support/core_ext'
require 'active_support/deprecation'
require 'rspec/rails'
require 'activerecord-nulldb-adapter'