Commit 95936623 by Vy Quoc Vu

better

parent efdd6311
class Admins::ProductsController < ApplicationController
before_action :sorl_init, only: [:create,:update, :destroy]
before_action :sorl_init, only: [:create,:edit, :destroy]
def sorl_init
@solr = RSolr.connect :url => Rails.configuration.solr_host.to_s
......@@ -58,9 +58,8 @@ class Admins::ProductsController < ApplicationController
def edit
if admin_signed_in?
if product_params && product_params[:price].to_i > 0 &&
params[:category][:id].to_i > 0 &&
params[:category][:id].to_i > 0 &&
!product_params[:image].nil? && !product_params[:image].empty? &&
!product_params[:price].empty? && !product_params[:name].empty? &&
product_params[:price].to_i <= 999999
......@@ -99,7 +98,6 @@ class Admins::ProductsController < ApplicationController
def destroy
if admin_signed_in?
byebug
@product = Product.find(params[:id])
@product.destroy
@solr.delete_by_query "id:#{params[:id]}"
......
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