Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/breeze/engine.rb
Instance Method Summary collapse
-
#breeze_routes(options = {}) ⇒ Object
breeze_routes will draw neccessary routes and possibly mount engine This includes: post /form for form processing get /news/:id for any news posts get /:id for any pages get /:lang/:id for every language and page redirects from any renamed page root to /index unless options == false mount the engine (make editing possible) unless production or oprions == true (not recommended).
Instance Method Details
#breeze_routes(options = {}) ⇒ Object
breeze_routes will draw neccessary routes and possibly mount engine This includes: post /form for form processing get /news/:id for any news posts get /:id for any pages get /:lang/:id for every language and page redirects from any renamed page root to /index unless options == false mount the engine (make editing possible) unless production
or oprions[:production] == true (not recommended)
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/breeze/engine.rb', line 66 def breeze_routes = {} Rails.application.routes.draw do begin if [:root] root "breeze/view#page" , id: 'index' end Breeze.language_strings.each do |lang| get "/#{lang}/:id" , to: "breeze/view#page" , lang: lang , id: :id get "/#{lang}" , to: "breeze/view#page" , lang: lang , id: 'index' end Breeze::Page.all.each do |page| next unless page.redirects page.redirects.split.each do |old| next if old == page.name get "/#{old}" => redirect("/#{page.name}") end end post "/form" , to: "breeze/form#post" , as: :post_form get "/news/:id" , to: "breeze/view#page" , id: :id , as: :view_blog get ":id" , to: "breeze/view#page" , id: :id , as: :view_page engine_path = [:path] || "/breeze" if ! Rails.env.production? or [:production].present? mount Breeze::Engine => engine_path end rescue => e puts e.backtrace raise e end end end |