5

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!

Ivan
  • 97,549
  • 17
  • 50
  • 58
  • 1
    Define "engine" in terms of what you're doing. – coreyward Feb 03 '11 at 18:38
  • I just created standard Rails Engine and I'm adding it as a gem on each app. – Ivan Feb 03 '11 at 19:17
  • What rails version are you using? in rails 2.3.* you could use config.plugin_paths = ["#{Rails.root}/vendor/plugins", "#{YOUR_PLUGIN_PATH}/vendor/plugins"] in your environment.rb – andrea Feb 03 '11 at 22:53
  • It's Rails 3, so I can't use your approach. I've found I can load the plugin by adding it's lib path to `$:` and requiring the `init.rb` file, but I'm not sure that's right and probably won't work for more complex plugins. – Ivan Feb 04 '11 at 15:22

1 Answers1

6

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 
Ivan
  • 97,549
  • 17
  • 50
  • 58