Multiple routing file in Rails 3
Rails 2.3 has an option to add more routes anytime using RouteSet#add_configuration_file.
Is it possible to do开发者_高级运维 the same in a Rails 3 project?
in config/application.rb:
config.paths.config.routes << File.join(Rails.root, "config/routes/route_file.rb")
In Rails 3.2 (possibly also Rails 3.1), use:
config.paths["config/routes"] << Rails.root.join('config/routes/route_file.rb')
To complete Joe Van Dyk's answer, to load all the files the the config/routes
directory, you must do (in Rails 3.2) :
config.paths["config/routes"] += Dir[Rails.root.join('config', 'routes', '*.rb').to_s]
This method is supported in Rails 3. http://apidock.com/rails/ActionController/Routing/RouteSet/add_configuration_file
Code example is, for example, here: http://sudomasochism.com/post/62151402/rails-2-3-0-and-routeset-add-configuration-file
精彩评论