Sha256: 297397734a5bfd50eed6530b1622abd4084703eba813719b0b20fd9caf6ad2e0
Contents?: true
Size: 1.26 KB
Versions: 12
Compression:
Stored size: 1.26 KB
Contents
module ActionDispatch::Routing # 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. class Mapper DEFAULT_CONTROLLER = "sitepress/site".freeze DEFAULT_ACTION = "show".freeze ROUTE_GLOB_KEY = "/*resource_path".freeze # Hook up all the Sitepress pages def sitepress_pages(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION, root: false, constraints: Sitepress::RouteConstraint.new) get ROUTE_GLOB_KEY, controller: controller, action: action, as: :page, format: false, constraints: constraints sitepress_root controller: controller, action: action if root end # Hook sitepress root up to the index of rails. 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 end end
Version data entries
12 entries across 12 versions & 1 rubygems