When upgrading engine from Rails 3.2 to Rails 4.2.0, the following inheritance in application controller causes circular dependency
error in rspec:
class ApplicationController < ApplicationController
end
We have config.eager_load = false
for config/development.rb.
The error:
activesupport-4.2.0/lib/active_support/dependencies.rb:492:in `load_missing_constant': Circular dependency detected while autoloading con
stant Authentify::ApplicationController (RuntimeError)
Here is the Rails engine document (ch:4.3.2) explaining this type of code practice. As I understand, the purpose of this inheritance is to allow the engine to access methods in Rails app or other engine which the current engine is mounted to. We would like to do the same in Rails 4.2.0 engine. How to fix this problem?
In rails 4 engine, the right format is:
class ApplicationController < ::ApplicationController
end
assume the class is within module MyEngine
. Or
class MyEngineName::ApplicationController < ::ApplicationController
end