开发者

How to load a Rails plugin from the site_ruby dir?

I have a plugin (called XYZ) installed in

/usr/lib/ruby/site_ruby/1.8/XYZ

Please note its not a rubygem but the "native" ruby sitelib library. Now.

I have added this line to the config/environment.rb:

config.gem "X开发者_JAVA百科YZ"

The problem here is Rails is not loading the plugin. Is there a trick to force loading from the ruby_site directory? Rails 2.3.10

Thanks


I'm still not sure why you're needing to do this (and I imagine there is a better way), but if this is your only option, then here goes...

Unlike gems which are just 'required', Rails loads plugins by running eval on the plugin's init.rb file (see here for 2.3.10 if you're interested). The 'site_ruby' folder is in Rails' load path, but files in there will be treated as normal libraries, not plugins.

To change this, you can easily add to Rails' load paths in your app config:

config.plugin_paths << "/usr/lib/ruby/site_ruby/1.8"

I don't have any experience with building RPM packages, but if it's forcing you to build your app in such a brittle way, then is it really the best way to distribute it? Just a thought! :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜