Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/sitepress/routing_mapper.rb
Overview
I have no idea how or why this works this way, I lifted the pattern from Devise, which came with even more weird stuff. Rails could use an API for adding route helpers to decrease the brittleness of this approach. For now, deal with this helper.
Constant Summary collapse
- DEFAULT_CONTROLLER =
"sitepress/site".freeze
- DEFAULT_ACTION =
"show".freeze
- ROUTE_GLOB_KEY =
"/*resource_path".freeze
Instance Method Summary collapse
-
#sitepress_pages(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION, root: false, constraints: Sitepress::RouteConstraint.new, as: :page) ⇒ Object
Hook up all the Sitepress pages.
-
#sitepress_root(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION) ⇒ Object
Hook sitepress root up to the index of rails.
Instance Method Details
#sitepress_pages(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION, root: false, constraints: Sitepress::RouteConstraint.new, as: :page) ⇒ Object
Hook up all the Sitepress pages
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sitepress/routing_mapper.rb', line 11 def sitepress_pages(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION, root: false, constraints: Sitepress::RouteConstraint.new, as: :page) get ROUTE_GLOB_KEY, controller: controller, action: action, as: as, format: false, constraints: constraints sitepress_root controller: controller, action: action if root end |
#sitepress_root(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION) ⇒ Object
Hook sitepress root up to the index of rails.
23 24 25 26 27 28 29 |
# File 'lib/sitepress/routing_mapper.rb', line 23 def sitepress_root(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION) if has_named_route? :root Rails.logger.warn "Sitepress tried to configured the 'root' route, but it was already defined. Check the 'routes.rb' file for a 'root' route or call 'sitepress_pages(root: false)'." else root controller: controller, action: action end end |