Sha256: 55584ca6c4911e93f6d58f0ecb573b5090accc637fda4c565b9f58e5407c0732

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

Rails.application.routes.draw do

  class PublicationConstraint
    def initialize; end
    def matches?(request)
      Publication.matching_slug(request.path.split('/')[-2]).count > 0 || Publication.matching_slug(request.path.split('/')[-1]).count > 0 || Publication.matching_slug(request.path.split('/')[-3]).count > 0
    end
  end

  class TestingConstraint
    def initialize; end
    def matches?(request)
      Rails.env == 'testing'
    end
  end

  constraints(TestingConstraint.new) do
    root :to => 'admin:publications#index'
  end

  constraints(PublicationConstraint.new) do
    match ':publication_slug/', :to => 'publications#show'
    match ':publication_slug/feed', :to => 'publications#feed', :format => [:rss]
    match ':publication_slug/:content_slug/:section_slug', :to => 'sections#show'
    match ':publication_slug/:content_slug/:filename', :to => 'managed_contents#show'
    match '/:publication_slug/:content_slug', :to => 'managed_contents#show'
  end

  namespace :admin do
    match 'publications/:publication_id/managed_contents/reorder', :to => 'managed_contents#reorder', :as => 'publication_reorder_managed_contents'
    match 'publications/:publication_id/managed_contents/:managed_content_id/sections/reorder', :to => 'sections#reorder', :as => 'publication_managed_content_reorder_sections'
    resources :publications do
      resources :managed_contents do
        collection do
          get 'import'
          post 'upload'
        end
        resources :sections
      end
    end
  end

  resources :publications, :only => :show do
    resources :managed_contents, :only => :show
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
editorial_logic-1.1.1 config/routes.rb
editorial_logic-1.1.0 config/routes.rb