Splitting Routes File Into Multiple Files
In Rails 3.2, config.paths is now a hash, so @sunkencity's solution can be modified to:
# config/application.rbconfig.paths["config/routes"] << File.join(Rails.root, "config/routes/fooroutes.rb")
Sunkencity's answer seems to be identical to the following link, but for completeness' sake: https://rails-bestpractices.com/posts/2011/05/04/split-route-namespaces-into-different-files/
Note that routes defined later will override routes defined earlier. However, if you use something like
config.paths.config.routes.concat( Dir[Rails.root.join('config/routes/*.rb')])
you don't know in what order the files will be read. So use
config.paths.config.routes.concat( Dir[Rails.root.join('config/routes/*.rb')].sort)
instead, so you at least know they will be in alphabetical order.
Add the route file to the app route loading path:
# config/application.rbconfig.paths.config.routes << File.join(Rails.root, "config/routes/fooroutes.rb")
Wrap your other route file in a block like this.
#config/routes/fooroutes.rbRails.application.routes.draw do |map| match 'FOO' => 'foo/bar'end
Works for me in rails 3.0