Jul 9, 2011

Rails plugin init.rb technique

Never ever do this in your init.rb


require 'db_migration'


Sure, Rails will automatically look into your plugin lib folder. But if another file with identical name is loaded before (from other plugin), then Rails won't look anywhere. It'll just grab that file.

Of course this is a behaviour that you don't want. You'd like each plugin to have its own space. Then, do this:


File.dirname(__FILE__)+'/lib/db_migration'