Class: TranslationCms::Routers::PostsRouter

Inherits:
Object
  • Object
show all
Defined in:
lib/translation_cms/routers/posts_router.rb

Class Method Summary collapse

Class Method Details

.loadObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/translation_cms/routers/posts_router.rb', line 7

def load
  Rails.application.routes.draw do
    if Structure.table_exists?
      root_structure = Structure.with_type(StructureType.posts).first
      if root_structure
        localized do
          scope page: /\d{1,5}/, per: /\d{1,3}/, id: /[a-zA-Z\d.,_-]{3,100}/,
                format: false, defaults: { format: 'html' } do
            get "/#{root_structure.slug}(/tag/:tag)(/p/:page)(/per/:per)",
                to: 'posts#index', as: :posts
            get "/#{root_structure.slug}/:id", to: 'posts#show', as: :post
            resources :posts, only: [], path: "/#{root_structure.slug}" do
              collection do
                get '/rss', to: 'feeds#index'
                get '/search(/p/:page)(/per/:per)', action: :search, as: :search
              end
            end
          end
        end
      end
    end
  end
end

.reloadObject



31
32
33
# File 'lib/translation_cms/routers/posts_router.rb', line 31

def reload
  Rails.application.routes_reloader.reload!
end