2015-02-23 3 views
2

У кого-нибудь есть идея, почему на моем производственном сервере я не могу использовать вложенные проблемы в модели?Циркулярная зависимость от вложенных проблем

У меня есть модель Landing

class Landing < ActiveRecord::Base 

    include Claimable 

end 

и забота

module Claimable 
    extend ActiveSupport::Concern 

end 

Все работает отлично, но запрашиваемое это stricly логика Landing, так что я хотел бы поставить его вложенный маршрут

class Landing < ActiveRecord::Base 

    include Landing::Claimable 

end 

и

module Landing::Claimable 
    extend ActiveSupport::Concern 

end 

Это работает на моей Developement машине (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 `<class:Landing>' 
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:18:in `<top (required)>' 
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 `<top (required)>' 
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 <module:Finisher>' 
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 `<top (required)>' 
from /home/app/app/current/config.ru:3:in `require' 
from /home/app/app/current/config.ru:3:in `block in <main>' 
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 `<main>' 
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 `<top (required)>' 
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 `<main>' 
+1

и есть класс Landing и спускаемого, делать и не думаю, что это слишком много? – CodeGroover

+0

удалите 'продление ActiveSupport :: Concern' с' Landing :: Claimable' –

+0

@CodeGroover Насколько это понятно, вот как работает пространство имен с проблемами. paritosh-piplewar. То же самое. – Michal

ответ

1

Это обычно связано с config.eager_load настройками на вашем приложении. У вас есть другая настройка в производственной среде от разработки, которая совершенно нормальная и предназначенная для использования, но именно поэтому вы сталкиваетесь с разными поведением от разработки до производства.

В качестве возможного решения я предлагаю избегать использования определения строк в однострочном пространстве имен и вместо этого менять его на несколько строк.

Попробуйте изменить:

module Landing::Claimable 
end 

к:

module Landing 
    module Claimable 
    end 
end 
+0

Как-то это сработало, спасибо. – Michal

+0

эй @ Мичал, не забудь про щедрость;) – dgilperez

+0

Я был уверен, я знал вас с этим, извините :) – Michal

Смежные вопросы