pdfshop/app/controllers/product_controller.rb

24 lines
556 B
Ruby

# All product logic for shop clients goes in here
class ProductController < ShopController
def index
if params[:search].blank?
@products = Product.page(params[:page])
else
@products = Product.where('active = 1 AND name LIKE ?',
"%#{params[:search]}%").page(params[:page])
end
end
def show
@product = Product.where('slug = ?', params[:id]).first
raise_404(@product)
render layout: false
end
private
def products_params
params.require(:product).permit(:search)
end
end