“config.cache_classes = true”没有要加载的文件 - / path-to-app / app / config / environment(LoadError)

时间:2011-08-18 12:07:21

标签: ruby-on-rails caching memcached production-environment

应用程序不会在config.cache_classes设置为true的生产模式下启动。它在stacktrace中给出以下错误:

    $ bundle exec rails s -e production
 /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:304:in `rescue in depend_on': No such file to load -- /path-to-app/app/config/environment (LoadError)
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:299:in `depend_on'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:216:in `require_dependency'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:137:in `each'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:137:in `block in eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:135:in `each'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:135:in `eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application.rb:108:in `eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
    from /path-to-app/config/environment.rb:5:in `<top (required)>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `block in require'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
    from /path-to-app/config.ru:3:in `block in <main>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
    from /path-to-app/config.ru:1:in `new'
    from /path-to-app/config.ru:1:in `<main>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'     
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands/server.rb:65:in `start'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:30:in `block in <top (required)>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

奇怪的是,它可以在缓存关闭时正常工作。我的production.rb文件看起来像

App::Application.configure do

    config.cache_classes = true  
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true 
    config.action_dispatch.x_sendfile_header = "X-Sendfile"
    config.action_mailer.delivery_method = :sendmail
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    config.serve_static_assets = false
    config.i18n.fallbacks = true
    config.active_support.deprecation = :notify
    config.action_dispatch.best_standards_support = :builtin
end

我正在使用以下宝石:

source 'http://rubygems.org'

gem 'rails', '3.0.7'

gem 'mysql2', '0.2.1'

gem 'carrierwave'

gem 'rmagick'

gem "capistrano-ext"

gem 'rake', '0.8.7'

group :development do

  gem 'rspec-rails', '2.1.0'

  gem 'ruby-debug19'

  gem 'wirble'

end

group :test do

  gem 'ruby-debug19'

  gem 'rspec', '2.1.0'

  gem 'webrat', '0.7.1'

  gem 'factory_girl_rails', '1.0'

end
gem 'thinking-sphinx', '2.0.3'

我非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

我知道,我做了一些愚蠢的事情(虽然不是我所有的,同样的旧设计师故事。我应该检查git提交)。我在app目录和项目目录中都有spec文件夹。但我仍然感到困惑,为什么它与

一起使用
config.cache_classes = false

在production.rb。