Method: Cms::RouteExtensions#content_blocks
- Defined in:
- lib/cms/route_extensions.rb
#content_blocks(content_block_name, options = {}, &block) ⇒ Object
Adds all necessary routes to manage a new content type. Works very similar to the Rails resources method, adding basic CRUD routes, as well as additional ones
for CMS specific routes (like versioning)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cms/route_extensions.rb', line 8 def content_blocks(content_block_name, ={}, & block) content_name = content_block_name.to_s.classify begin content_block = "#{Cms::Module.current_namespace}::#{content_name}".constantize rescue NameError content_block = content_name.constantize end resources content_block_name do member do put :publish if content_block.publishable? get :versions if content_block.versioned? get :usages if content_block.connectable? end end if content_block.versioned? send("get", "/#{content_block_name}/:id/version/:version", :to=>"#{content_block_name}#version", :as=>"version_cms_#{content_block_name}".to_sym) send("put", "/#{content_block_name}/:id/revert_to/:version", :to=>"#{content_block_name}#revert_to", :as=>"revert_to_cms_#{content_block_name}".to_sym) end end |