method
draw
v7.2.3 -
Show latest stable
- Class:
ActionDispatch::Routing::Mapper::Mapping::Scoping::Resources
draw(name)public
Loads another routes file with the given `name` located inside the `config/routes` directory. In that file, you can use the normal routing DSL, but *do not* surround it with a `Rails.application.routes.draw` block.
# config/routes.rb Rails.application.routes.draw do draw :admin # Loads `config/routes/admin.rb` draw "third_party/some_gem" # Loads `config/routes/third_party/some_gem.rb` end # config/routes/admin.rb namespace :admin do resources :accounts end # config/routes/third_party/some_gem.rb mount SomeGem::Engine, at: "/some_gem"
*CAUTION:* Use this feature with care. Having multiple routes files can negatively impact discoverability and readability. For most applications â even those with a few hundred routes â it’s easier for developers to have a single routes file.