Rails 3: turning on the plug-in inside the engine

I know this sounds a little natural, but I am creating an engine that will enable and bind several applications, and since all applications will use this plugin, I was wondering if I could just add the plugin to the engine.

So I put it inside the vendor / plugins, but it doesn't seem to be loaded.

I played with autoload_pathsand require, but I was not successful.

Does anyone know if this is possible? Or do you have an idea for what I can try?

Thank!

+5
source share
1 answer

After some attempts, this is what I found work and seems correct:

module MyEngine 
  class Engine < Rails::Engine 
    config.after_initialize do 
      Rails.application.config.paths.vendor.plugins.push File.expand_path('../../vendor/plugins', __FILE__) 
    end 
  end 
end 
+6
source

All Articles