The way to add before_filter from the engine to the application

Without a lot of code, this is just vague, but I will provide everything I can.

Given that the rails engine is a base engine, not a mounted engine in its own space, how do I make methods from a mechanism available to an application like before_filter for application controllers?

I am reviewing Devise code because what I want is similar to my experience with Devise, but I admit that I don’t understand a lot of what I am going through.

I can do this if I put include Myengine::Mymodulein application controllers where I want the methods to be available for filtering, but I want to be able to just use the methods without having to include modules.

This is the last roadblock in an attempt to turn the rails application into an engine that will be used by several rail applications, and any recommendations for getting a descriptor for the correct namespace, module configuration, etc. appreciated.

+5
source share
1 answer

If you understand correctly, you can use an initializer, for example:

module MyEngine
    class Engine < Rails::Engine
        initializer  "myengine.load_helpers" do
            ActiveSupport.on_load(:action_controller) do
                include MyEngine::Helpers
            end
        end
    end
end
+5
source

All Articles