module ActionDispatch::Routing::Mapper::Resources
def draw(name)
applications — even those with a few hundred routes — it's easier for
files can negatively impact discoverability and readability. For most
CAUTION: Use this feature with care. Having multiple routes
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
+Rails.application.routes.draw+ block.
routing DSL, but do not surround it with a
+config/routes+ directory. In that file, you can use the normal
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