嵌套关注的循环依赖

任何人都知道为什么,在我的生产服务器上我不能在模型中使用嵌套关注点?

我有一个模型Landing

 class Landing < ActiveRecord::Base include Claimable end 

和关注

 module Claimable extend ActiveSupport::Concern end 

一切都工作正常,但Claimable严格登陆逻辑,所以我想把它作为一个嵌套的路线

 class Landing < ActiveRecord::Base include Landing::Claimable end 

  module Landing::Claimable extend ActiveSupport::Concern end 

这是在我的开发机器(OSX Yosemite)上工作,但当我部署到Linux生产服务器时,我收到错误:

 /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:492:in `load_missing_constant': Circular dependency detected while autoloading constant Landing::Claimable (RuntimeError) from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:20:in `' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:18:in `' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:360:in `require_or_load' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:494:in `load_missing_constant' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/concerns/landing/claimable.rb:1:in `' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:360:in `require_or_load' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:317:in `depend_on' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:233:in `require_dependency' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:471:in `each' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:471:in `block in eager_load!' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:469:in `each' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:469:in `eager_load!' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:346:in `eager_load!' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `each' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `block in ' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each' from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!' from /home/app/app/current/config/environment.rb:5:in `' from /home/app/app/current/config.ru:3:in `require' from /home/app/app/current/config.ru:3:in `block in ' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize' from /home/app/app/current/config.ru:1:in `new' from /home/app/app/current/config.ru:1:in `' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `eval' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `load' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:42:in `for' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:170:in `load_adapter' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:74:in `start' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!' from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/bin/thin:6:in `' from /home/app/app/releases/68f6492bb01f28373b95f26f34b609fdb99dc9cd/vendor/bundle/bin/thin:16:in `load' from /home/app/app/releases/68f6492bb01f28373b95f26f34b609fdb99dc9cd/vendor/bundle/bin/thin:16:in `' 

这通常与您的应用程序上的config.eager_load设置有关。 您在生产环境中具有与开发环境不同的设置,这是完全正常的和预期用途,但这就是您从开发到生产体验不同行为的原因。

作为一种可能的解决方案,我建议您避免使用单行命名空间类定义,而是将其更改为多行。

尝试改变:

 module Landing::Claimable end 

至:

 module Landing module Claimable end end