helper to create all routes
This commit is contained in:
parent
926f6ef197
commit
a95c97c7ea
@ -31,6 +31,35 @@ module Merged
|
||||
config.assets.precompile << kid
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
module ActionDispatch::Routing
|
||||
class Mapper
|
||||
|
||||
# merged_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
|
||||
# root to /index unless options[:root] == false
|
||||
# mount the engine (make editing possible) unless production
|
||||
# or oprions[:production] == true (not recommended)
|
||||
def merged_routes options = {}
|
||||
Rails.application.routes.draw do
|
||||
if options[:root]
|
||||
root "merged/view#page" , id: 'index'
|
||||
end
|
||||
|
||||
post "/form" , to: "merged/form#post" , as: :post_form
|
||||
get "/news/:id" , to: "merged/view#page" , id: :id , as: :view_blog
|
||||
get ":id" , to: "merged/view#page" , id: :id , as: :view_page
|
||||
|
||||
engine_path = options[:path] || "/merged"
|
||||
if ! Rails.env.production? or !options[:production].truthy?
|
||||
mount Merged::Engine => engine_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,6 @@
|
||||
Rails.application.routes.draw do
|
||||
mount Merged::Engine => "/merged"
|
||||
|
||||
get ":id" , to: "merged/view#page" , id: :id
|
||||
merged_routes
|
||||
|
||||
get :destroy_member_session , to: "merged/view#page"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user