pdfshop/app/controllers/product_controller.rb

28 lines
601 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)
respond_to do |format|
format.html
format.js
end
end
private
def products_params
params.require(:product).permit(:search)
end
end