我在尝试运行rspec时遇到此错误,我正在使用:
rails 4.2.4ruby 2.2.2carrierwave 0.10.0
我能做什么?!

/home/adham/.rvm/gems/ruby-2.2.2/gems/carrierwave-0.10.0/lib/carrierwave/orm/activerecord.rb:9:in `<module:ActiveRecord>': uninitialized constant CarrierWave::Mount (NameError)
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/carrierwave-0.10.0/lib/carrierwave/orm/activerecord.rb:7:in `<module:CarrierWave>'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/carrierwave-0.10.0/lib/carrierwave/orm/activerecord.rb:6:in `<top (required)>'
    from /home/adham/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
    from /home/adham/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
    from /home/adham/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    from /home/code/bedo/config/environment.rb:2:in `<top (required)>'
    from /home/adham/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/adham/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/code/bedo/spec/rails_helper.rb:2:in `<top (required)>'
    from /home/adham/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/adham/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/code/bedo/spec/controllers/assignments_controller_spec.rb:1:in `<top (required)>'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
    from /home/adham/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'
    from /home/adham/.rvm/gems/ruby-2.2.2/bin/rspec:23:in `load'
    from /home/adham/.rvm/gems/ruby-2.2.2/bin/rspec:23:in `<main>'

最佳答案

我通过在carrierwave orm文件中请求application文件后请求config/environment.rb来解决这个问题。
require File.expand_path('../application', __FILE__)require 'carrierwave/orm/activerecord'

关于ruby-on-rails - '<module:ActiveRecord>':未初始化的常量CarrierWave::Mount(NameError),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33482399/

10-13 07:27