Sha256: cd602cf1025a5089b9689342f5dcbb77d34d4c007c6599ac90a7b70f673b0653
Contents?: true
Size: 812 Bytes
Versions: 6
Compression:
Stored size: 812 Bytes
Contents
module PowerShop class CatalogController < PowerShop::ApplicationController # Public: show all products with pagination # # Returns: text/html def index @products = scoped_products.page(params[:page]) end # Public: show products inside current category # # Returns: text/html def category @category = ::Category.friendly.find(params[:id]) @products = scoped_products.where(category: @category).page(params[:page]) end # Public: show detail page for product # # Returns text/html def product @category = ::Category.friendly.find(params[:category_id]) @product = scoped_products.friendly.find(params[:id]) end protected def scoped_products ::Product.active.includes(:images, :category) end end end
Version data entries
6 entries across 6 versions & 1 rubygems