Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- 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
-
#draw(routes_name) ⇒ Object
Method for organizing the routes file into multiple files.
-
#draw_static_pages ⇒ Object
Method for drawing the routes for static pages automatically.
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_pages ⇒ Object
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.
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 |