File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
actionpack/lib/action_dispatch/routing Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -1584,6 +1584,29 @@ def shallow?
15841584 !parent_resource . singleton? && @scope [ :shallow ]
15851585 end
15861586
1587+ # Loads another routes file with the given +name+ located inside the
1588+ # +config/routes+ directory. In that file, you can use the normal
1589+ # routing DSL, but <i>do not</i> surround it with a
1590+ # +Rails.application.routes.draw+ block.
1591+ #
1592+ # # config/routes.rb
1593+ # Rails.application.routes.draw do
1594+ # draw :admin # Loads `config/routes/admin.rb`
1595+ # draw "third_party/some_gem" # Loads `config/routes/third_party/some_gem.rb`
1596+ # end
1597+ #
1598+ # # config/routes/admin.rb
1599+ # namespace :admin do
1600+ # resources :accounts
1601+ # end
1602+ #
1603+ # # config/routes/third_party/some_gem.rb
1604+ # mount SomeGem::Engine, at: "/some_gem"
1605+ #
1606+ # <b>CAUTION:</b> Use this feature with care. Having multiple routes
1607+ # files can negatively impact discoverability and readability. For most
1608+ # applications — even those with a few hundred routes — it's easier for
1609+ # developers to have a single routes file.
15871610 def draw ( name )
15881611 path = @draw_paths . find do |_path |
15891612 File . exist? "#{ _path } /#{ name } .rb"
Original file line number Diff line number Diff line change @@ -1273,7 +1273,7 @@ video = Video.find_by(identifier: "Roman-Holiday")
12731273edit_video_path(video) # => "/videos/Roman-Holiday/edit"
12741274```
12751275
1276- Breaking Up * Very* Large Route File into Multiple Small Ones:
1276+ Breaking Up * Very* Large Route File into Multiple Small Ones
12771277-------------------------------------------------------
12781278
12791279If you work in a large application with thousands of routes, a single ` config/routes.rb ` file can become cumbersome and hard to read.
You can’t perform that action at this time.
0 commit comments