From 1b9b765240e92bcf1789d75aa88b4abb269372c5 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Fri, 19 Apr 2019 21:33:40 +0200 Subject: [PATCH] List all products --- app/controllers/products_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 9504241..6a4a9c0 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -48,8 +48,10 @@ class ProductsController < ApplicationController def index @products = Product.all @categories = Product.categories - - render 'products_list/listview' if current_user.admin? + respond_to do |format| + format.json { render json: @products } + format.html { render 'products_list/listview' if current_user.admin? } + end end def edit