refacto
This commit is contained in:
parent
9f23908f7f
commit
e45208a394
@ -18,9 +18,7 @@ class Admin::PProductRefsController < ApplicationController
|
|||||||
|
|
||||||
# @purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all
|
# @purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all
|
||||||
|
|
||||||
global_search_ids = @p_product_refs.ids
|
global_search_ids = p_product_ref_cat_id_ids = s_brand_id_ids = @p_product_refs.ids
|
||||||
p_product_ref_cat_id_ids = @p_product_refs.ids
|
|
||||||
s_brand_id_ids = @p_product_refs.ids
|
|
||||||
|
|
||||||
if params[:search][:global].to_s != ""
|
if params[:search][:global].to_s != ""
|
||||||
global_search_ids = PProductRef.global_search(params[:search][:global]).ids
|
global_search_ids = PProductRef.global_search(params[:search][:global]).ids
|
||||||
@ -52,13 +50,11 @@ class Admin::PProductRefsController < ApplicationController
|
|||||||
s_brand_id_ids = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}).ids
|
s_brand_id_ids = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}).ids
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
final_ids = global_search_ids & p_product_ref_cat_id_ids & s_brand_id_ids
|
final_ids = global_search_ids & p_product_ref_cat_id_ids & s_brand_id_ids
|
||||||
|
|
||||||
if params[:search].present?
|
@p_product_refs = PProductRef.where(id: final_ids)
|
||||||
@p_product_refs = PProductRef.where(id: final_ids)
|
|
||||||
else
|
|
||||||
@p_product_refs = PProductRef.joins(:p_product)
|
|
||||||
end
|
|
||||||
|
|
||||||
@p_product_refs = sort_by_sorting(@p_product_refs, "id DESC")
|
@p_product_refs = sort_by_sorting(@p_product_refs, "id DESC")
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
Reference in New Issue
Block a user