Module: ActionDispatch::DrawAll

Defined in:
lib/action_dispatch/draw_all.rb,
lib/action_dispatch/draw_all/version.rb

Constant Summary collapse

RoutesNotFound =
Class.new(StandardError)
VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#draw_all(routes_name) ⇒ Object

Draws all matching files located inside the config/routes directories

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/action_dispatch/draw_all.rb', line 10

def draw_all(routes_name)
  drawn_any = false

  Rails.application.config.paths['config/routes'].paths.each do |path|
    route_path = path.join("#{routes_name}.rb")

    drawn_any |= draw_route(route_path)
  end

  return if drawn_any

  msg  = "Your router tried to #draw_all the external file #{routes_name}.rb,\n" \
    "but the file was not found in:\n\n"
  msg += Rails.application.config.paths['config/routes']
    .paths
    .map { |path| " * #{path}" }.join("\n")

  raise RoutesNotFound, msg
end