Sha256: ce5d66ef326c1ea0b6aa72539121aeb3cb90ba4f67352a53da066264f38a24f0

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# Routes for admin interface
Cardboard::Engine.routes.draw do

  get "my_account", to: "my_account#edit"
  patch "my_account", to: "my_account#update"

  get "pages/new", to: "pages#new"
  post "pages/sort", to: "pages#sort"
  get "pages/:id", to: "pages#edit"
  
  resources :pages

  get "/yoda", to: "super_user#index"

  get "/settings", to: "settings#index"
  patch "/settings/update", to: "settings#update", as: "setting"

  get "/", to: "dashboard#index", as: "dashboard"
  #Don't put a root path here, use "/" instead... (to be able to use root_path in the pages)

  
  scope as: 'cardboard' do
    #generate routes for custom cardboard resources controllers
    Cardboard.resource_controllers.each do |controller|
      if controller.singular?
        # Singular controller names are non-standard in rails.  We must specify the
        # controller explicitly here to keep the name from 
        # being pluralized in the route.
        resource controller.controller_name, controller: controller.controller_name
      else
        resources controller.controller_name
      end
    end
  end

end

# Routes for public pages
Rails.application.routes.draw do
  scope  :constraints => { :format => 'html' } do #:format => true,
    get "*id", to: "pages#show"
  end

  root :to => "pages#show" unless @set.named_routes.routes[:root] #has_named_route?
end


Rails.application.routes.named_routes.module.module_eval do
  def page_path(identifier, options = {})
    url = Cardboard::Page.where(identifier: identifier.to_s).first.try(:url)
    options.present? && url ? "#{url}?#{options.to_query}" : url
  end

  def page_url(identifier, options = {})
    return nil unless url = page_path(identifier, options)
    root_url + url[1..-1]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cardboard_cms-0.2.2 config/routes.rb