Sha256: bf8ecf5b16c2977feacb8515d5c3b7572945cd74704df3a94046f4858d845f8e

Contents?: true

Size: 991 Bytes

Versions: 3

Compression:

Stored size: 991 Bytes

Contents

module ActionDispatch::Routing
  class Mapper

    def enjoy_cms_catalog_routes(config = {})
      routes_config = {
        use_items_path: true,
        use_item_categories_path: true,
        use_catalog_path: true
      }
      routes_config.merge!(config)

      scope module: 'enjoy' do
        scope module: 'catalog' do
          if routes_config[:use_items_path]
            resources :items, only: [:show], as: :enjoy_catalog_items do
              get '(/page/:page)', action: :index, on: :collection, as: ""
            end
          end

          if routes_config[:use_item_categories_path]
            resources :item_categories, only: [:index, :show], as: :enjoy_catalog_item_categories do
              get 'items(/page/:page)', action: :items, on: :member, as: :items
            end
          end
          if routes_config[:use_catalog_path]
            get 'catalog' => 'item_categories#index', as: :enjoy_catalog
          end
        end
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enjoy_cms_catalog-0.3.7 lib/enjoy/catalog/routes.rb
enjoy_cms_catalog-0.3.6 lib/enjoy/catalog/routes.rb
enjoy_cms_catalog-0.3.5 lib/enjoy/catalog/routes.rb