Commit 17b967c5 by Nguyen Quoc Kien

New brach review code

parent ab64a07d
class Admin::CartsController < ApplicationController class Admin::CartsController < ApplicationController
before_action :authenticate_admin! before_action :authenticate_admin!
def index def index
@users = User.all @users = User.all
end end
...@@ -25,4 +25,5 @@ class Admin::CartsController < ApplicationController ...@@ -25,4 +25,5 @@ class Admin::CartsController < ApplicationController
@cart.update(status: status) @cart.update(status: status)
redirect_to admin_cart_path(id: params[:user_id]) redirect_to admin_cart_path(id: params[:user_id])
end end
end end
...@@ -58,6 +58,7 @@ class Admin::ProductsController < ApplicationController ...@@ -58,6 +58,7 @@ class Admin::ProductsController < ApplicationController
end end
private private
def find_product def find_product
@product = Product.find(params[:id]) @product = Product.find(params[:id])
end end
......
class Admin::UsersController < ApplicationController class Admin::UsersController < ApplicationController
before_action :authenticate_admin! before_action :authenticate_admin!
def index
@users = User.paginate(page: params[:page]).per_page(21)
end
def destroy def index
@user = User.find(params[:id]) @users = User.paginate(page: params[:page]).per_page(21)
if @user.destroy end
def destroy
@user = User.find(params[:id])
if @user.destroy
flash[:success] = "Delete User : Success" flash[:success] = "Delete User : Success"
else else
flash[:danger] = "Delete User : Error" flash[:danger] = "Delete User : Error"
end end
redirect_to admin_users_path redirect_to admin_users_path
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment