Class: PowerShop::CatalogController

Inherits:
ApplicationController show all
Defined in:
app/controllers/power_shop/catalog_controller.rb

Direct Known Subclasses

CatalogController

Instance Method Summary collapse

Methods inherited from ApplicationController

#cart

Instance Method Details

#categoryObject

Public: show products inside current category

Returns: text/html



13
14
15
16
# File 'app/controllers/power_shop/catalog_controller.rb', line 13

def category
  @category = ::Category.friendly.find(params[:id])
  @products = scoped_products.where(category: @category).page(params[:page])
end

#indexObject

Public: show all products with pagination

Returns: text/html



6
7
8
# File 'app/controllers/power_shop/catalog_controller.rb', line 6

def index
  @products = scoped_products.page(params[:page])
end

#productObject

Public: show detail page for product

Returns text/html



21
22
23
24
# File 'app/controllers/power_shop/catalog_controller.rb', line 21

def product
  @category = ::Category.friendly.find(params[:category_id])
  @product = scoped_products.friendly.find(params[:id])
end