Sha256: d9d1051a7b25425f03e19af10db1120c063a86c971712ef260a04423568f10d1

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

PagesCms::Engine.routes.draw do

  resources :articles,    only: [:show]
  resources :contacts,    only: [:create]

  namespace :admin do
    resources :pages,     except: [:show, :new]
    resources :images,    only:   [:create, :index, :destroy]
    resources :documents, only:   [:create, :index, :destroy]
    resources :articles,  only:   [:index, :create, :update, :destroy]
    resources :contacts,  only:   [:index, :destroy]
    resources :accounts,  except: [:show]
    post '/pages/order'   => 'pages#order'
    post '/accounts/site' => 'accounts#site'
  end

  # # mainly for deploying to heroku, keeps it from throwing an error before the db is deployed.
  # def db_exists?
  #   ActiveRecord::Base.connection
  # rescue ActiveRecord::NoDatabaseError
  #   false
  # else
  #   true
  # end
  # db_exists? &&

  # draws all the routes for the CMS. The root account (raccount) is drawn last to avoid conflicts.
  # :slug is the main way to identify the page, as well as the account.id.
  if PagesCms.const_defined?('Account')
    accounts = PagesCms::Account.where("mount_location != '/'")
    raccount = PagesCms::Account.find_by(mount_location: '/')
    if accounts
      accounts.each do |account|
        get "/#{account.mount_location}/:parent/:slug"  => 'pages#show', account: account.id
        get "/#{account.mount_location}/:slug"          => 'pages#show', account: account.id
        get "/#{account.mount_location}/"               => 'pages#home', account: account.id
      end
    end
    if raccount
      get '/:parent/:slug'  => 'pages#show', account: raccount.id, root: true
      get '/:slug'          => 'pages#show', account: raccount.id, root: true
      get '/'               => 'pages#home', account: raccount.id, root: true, as: :root
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_cms-2.3.1 config/routes.rb