Accessing helpers from the parent app in an isolated Rails engine
You can expose the implementing application's helpers available to the engine by including the following code in your engine.rb file:
engine.rb
module MyBigFancyEngine
class Engine < Rails::Engine
isolate_namespace MyBigFancyEngine
config.to_prepare do
# Make the implementing application's helpers available to the engine.
# This is required for the overriding of engine views and helpers to work correctly.
MyBigFancyEngine::ApplicationController.helper Rails.application.helpers
end
end
end
The RailsAdmin Engine is also isolated, but they have the same configuration options as you would like to implement. They have configurable before_filters for both authentication and authorization. Have a look at this.
As far as I can tell, they just subclass the parent controller like this::ApplicationController
or instead you can configure one (ref).
For your controller you could just create your own EngineController
, that inherits from RocketPant::Base
and maybe just create a method there that calls the configured authentication method directly via send
on the parent controller.
As the RocketPant::Base
Class does not inherit from ApplicationController::Base
I guess you have to find some custom way around this and can't go the normal ways for Rails Engines. Maybe you could also try to file an issue to the rocket_pant repo, to add the helper
method. As far as I read they soon want to inherit from ApplicationController::Base
anyway in 2.0 (ref).