module ActionDispatch::Routing::Mapper::Resources
def draw(name)
even those with a few hundred routes — it's easier for developers to have a
negatively impact discoverability and readability. For most applications —
**CAUTION:** Use this feature with care. Having multiple routes files can
mount SomeGem::Engine, at: "/some_gem"
# config/routes/third_party/some_gem.rb
end
resources :accounts
namespace :admin do
# config/routes/admin.rb
end
draw "third_party/some_gem" # Loads `config/routes/third_party/some_gem.rb`
draw :admin # Loads `config/routes/admin.rb`
Rails.application.routes.draw do
# config/routes.rb
but *do not* surround it with a `Rails.application.routes.draw` block.
`config/routes` directory. In that file, you can use the normal routing DSL,
Loads another routes file with the given `name` located inside the
def draw(name) path = @draw_paths.find do |_path| File.exist? "#{_path}/#{name}.rb" end unless path msg = "Your router tried to #draw the external file #{name}.rb,\n" \ "but the file was not found in:\n\n" msg += @draw_paths.map { |_path| " * #{_path}" }.join("\n") raise ArgumentError, msg end route_path = "#{path}/#{name}.rb" instance_eval(File.read(route_path), route_path.to_s) end