Rails 2.3.0 and RouteSet#add_configuration_file

I’ve moved one of our projects over to edge rails after hearing about the new support for multiple routes files. I’ve been wanting this for a long time. It’s pretty easy to setup too:

First, make your custom routes file in config/

config/routes_custom.rb

ActionController::Routing::Routes.draw do |map|
  map.namespace :admin do |admin|
    admin.resources :manufacturers
  end
end

Next, add an initializer to load that routes file on boot:

config/initializers/load_custom_routes.rb

ActionController::Routing::Routes.add_configuration_file(File.join(RAILS_ROOT, 'config', 'routes_custom.rb'))

If you clone from a master repo for custom projects, this is ideal as it won’t muck up the core routes file annoying you with conflicts and such.