Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3: Including a plugin inside an engine

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!

like image 287
Ivan Avatar asked Feb 03 '11 18:02

Ivan


1 Answers

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 
like image 115
Ivan Avatar answered Oct 20 '22 13:10

Ivan