Commit 26aab3c8 by Tran Hoang Viet

VietTH: Fix review code feature search

parent 5a3bd5d8
class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
layout Proc.new { |controller| controller.devise_controller? ? 'devise' : 'application' }
# Prevent CSRF attacks by raising an exception.
......@@ -14,4 +15,8 @@ class ApplicationController < ActionController::Base
def add_breadcrumb_home
add_breadcrumb('Home', root_path)
end
def record_not_found
redirect_to(root_path, alert: "Resource not found")
end
end
\ No newline at end of file
......@@ -7,8 +7,7 @@ class CategoriesController < ApplicationController
private
def set_category
@category = Category.find_by(id: params[:id])
redirect_to root_path, alert: "Category not found" if @category.blank?
@category = Category.find(params[:id])
end
end
\ No newline at end of file
......@@ -10,7 +10,7 @@ class OrdersController < ApplicationController
def create
if order_service.create(order_params)
clear_cart
redirect_to root_path
redirect_to(root_path, notice: 'Checkout is successful.')
else
render :index
end
......
......@@ -14,9 +14,9 @@ class ProductsController < ApplicationController
def create
@product = Product.new(product_params)
if @product.save
redirect_to root_path
redirect_to(root_path)
else
render :new
render(:new)
end
end
......@@ -26,8 +26,8 @@ class ProductsController < ApplicationController
end
def add_cart
add_to_cart @product
redirect_to @product
add_to_cart(@product)
redirect_to(@product, notice: 'Product is added to cart.')
end
def search
......@@ -37,8 +37,7 @@ class ProductsController < ApplicationController
private
def set_product
@product = Product.find_by(id: params[:id])
redirect_to root_path, alert: "Product not found" if @product.blank?
@product = Product.find(params[:id])
end
def set_categories
......
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