Plugin loading internals have changed, for the better!
Posted by marcel March 02, 2007 @ 09:01 AM
Until now, the task of locating and loading plugins into your app was handled by a handful of private methods on the Rails::Initializer. These methods were fairly large, coarse grained, and as a result hard to hook into without resorting to fragile cut and paste if you wanted to customize how your plugins are loaded.
New in Edge Rails, changeset 6277 replaces this smattering of methods with two new internal classes, Rails::Plugin::Locater and Rails::Plugin::Loader. If you need to hook into how plugins are loaded, you can define a subclass of Rails::Plugin::Loader, then register your custom class to be the class that handles plugin loading using the new plugin_loader configuration option in your config/environement.rb:
Rails::Initializer.run do |config|
# Config settings...
config.plugin_loader = PluginLoaderWithDependencies
end
This should make extensions on top of the plugin system, such as the Plugems approach developed by the team over at Revolution Health, far easier to implement and maintain.
To those monkey patching the plugin loading subsystem in Rails, this introduces substantial changes to the way that plugins are located and loaded. In the short term this might mean that your customizations to the internals will very likely break, but the good news is that in the long term the new implementation will be far easier to customize.
For those adventurous early adopters living on the Rails Edge, please give your apps a test run to ensure these changes don’t break anything for you. As always, bug reports and patches are welcome: http://dev.rubyonrails.org/.

This is cool, but I feel duty-bound to inform you that it Locater should be spelt Locator. ;)
I wanted to second Luke, but I’ve just discovered ‘locater’ is actually in the American Heritage Dictionary.
Since I fought with my copy editors to be able to spell certain words in their lesser used fashion (like ‘acknowledgement’ rather than the more dull ‘acknowledgment’) I’m going to support locater on this one just out of principle ;-)
Marcel,
Awesome! Thanks for making our move from 1.1 to 1.2/Edge easier. Any chance of this patch becoming part of a release prior to 2.0? As we move plugems from 1.1 to 1.2+, I’d love to be able to leverage these changes as soon as possible.
Thanks,
Aaron Batalion Portal Architect www.revolutionhealth.com
Aaron, we’re going to be pushing out a 1.2.3 release soon and if this passes muster it will likely be included in that.
I also had to look twice at ‘locater’.
The very authoritative Googlefight agrees with Mr. Redpath, and so do I.
Locater vs. Locator
Yes. When I started implementing the code my brain typed out locator. Then I think I was talking about it in Rails core and Firefox dutifully underlined the word in red, so I thought, “Oh no I’ve misspelled it”. Then I looked up locater (no red underline! looks promising) and found a definition for it, so it seemed persuasive that that was the correct spelling. In other words, I blame Firefox for sending me astray. There are more changes to come. One of them will be correcting the spelling :)
Very cool, thanks Marcel.
Spelling change, among on things, in http://dev.rubyonrails.org/changeset/6290.
Let me see if my grammer is right on my calender.
I just noticed that Marcel’s name is not listed as an employee of 37signals, where did he go?
http://rubyonrails.org/core says Marcel is now with FiveRuns. http://fiveruns.com/
Congrats and best wishes, Marcel!
Check out my new inline console plugin :
http://inline-ruby-console.googlecode.com/svn/inline_console
It provides a script\console type interface within the browser.
cheers
weepy
Wonderful!
And fiveruns looks really promising, too.
Thanks Marcel!
I am looking around for some weeks to find a way to understand Rails. I learnd that ruby and Rails must come from other OS than Windows. In all examples you are using dos boxes as used in the last century. Do you know that tere is an Editor with the name RIDE ME (http://www.projectrideme.com/). The Editor looks like thr Editor of microsofts Visual studio and the IDE from Sun Micro-Systems with the name Netbeans. Please let me know if there are more user using RIDE ME.
I am located in Germany and i have had a look to the rubyonrails.de page. It looks like a copy of the American page. It would be nice if the German language would used for the frame and the contents. The advertisements of books in english language can be read from the american page. Need more content from the German user groups.
Regards Robert.
Excellent post from Robert Versluis.
Why doesn’t this blog have moderation?
The above message isn’t really spam. Off-topic maybe, but that’s okay. All comments are passed through Akismet though.
If I could just learn to spell.. Cool blog, guys !
hi test