Rails 3: Including a plugin inside an engine

909 views Asked by At

I know it sounds kinda nuts, but I'm building an engine that will power and tie several applications, and since all applications will use a given plugin, I was wondering whether I could just put the plugin in the engine.

So I put it inside vendor/plugins, but it appears it isn't loaded.

I've been playing with autoload_paths and require, but I haven't been successful.

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

Thanks!

1

There are 1 answers

0
Ivan On

After some fiddling, this is what I found works 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