Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/action_dispatch/routing/mapper.rb

Overview

Hacking on ActionDispatch::Routing::Mapper provides additional methods for defining routes. These include being able to organize routes into multiple files and a whole lot of magic for generating routes and controllers for static pages.

Instance Method Summary collapse

Instance Method Details

#draw(routes_name) ⇒ Object

Method for organizing the routes file into multiple files



9
10
11
# File 'lib/extensions/action_dispatch/routing/mapper.rb', line 9

def draw(routes_name)
  instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end

#draw_static_pagesObject

Method for drawing the routes for static pages automatically. Any .html.erb file in ‘app/views/pages` will be served as the dasherized file name.

Examples:

about_us.html.erb will be served at http:/example/about-us
and the link helper will be available as `about_us_path`


18
19
20
21
22
# File 'lib/extensions/action_dispatch/routing/mapper.rb', line 18

def draw_static_pages
  draw_routes
  generate_controller
  draw_sub_pages
end