Reputation: 2819
I have an engine called Admin and a few controllers.
# admin/app/controllers/admin/application_controller.rb
module Admin
class ApplicationController < ActionController::Base
end
end
# admin/app/controllers/admin/foo_controller.rb
module Admin
class CardsController < ApplicationController
end
end
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
If I visit my main app and THEN /admin the CardsController
inherits from ApplicationController
NOT Admin::ApplicationController
. If I first visit /admin and then the main app it works.
I guess that when we first visit the main app the constant ApplicationController
is created, which is then found and used when visiting /admin instead of loading Admin::ApplicationController
.
How can one avoid this issue?
Upvotes: 1
Views: 1169
Reputation: 18888
You'll have to be specific about which class you are inheriting from:
module Admin
class CardsController < Admin::ApplicationController
# ...
end
end
Upvotes: 4