Class: Workarea::Api::Storefront::CategoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/api/storefront/categories_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#assert_current_metrics_id, #cache_page, #skip_session

Methods included from Authentication

#authentication?, #current_user, find_user

Instance Method Details

#indexObject



7
8
9
10
11
12
13
# File 'app/controllers/workarea/api/storefront/categories_controller.rb', line 7

def index
  models = Catalog::Category.page(params[:page]).select(&:active?)
  @categories = Workarea::Storefront::CategoryViewModel.wrap(
    models,
    view_model_options
  )
end

#showObject

Raises:

  • (InvalidDisplay)


15
16
17
18
19
20
21
22
23
# File 'app/controllers/workarea/api/storefront/categories_controller.rb', line 15

def show
  model = Catalog::Category.find_by(slug: params[:id])
  raise InvalidDisplay unless model.active?

  @category = Workarea::Storefront::CategoryViewModel.wrap(
    model,
    view_model_options
  )
end