Created
December 1, 2011 18:48
-
-
Save markoh/1418917 to your computer and use it in GitHub Desktop.
Revisions
-
markoh created this gist
Dec 1, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ def self.search_filter(name,manufacture_id,product_type_id) f_name = "'%#{name}%'" f_manufacture_id = manufacture_id f_manufacture_id = f_manufacture_id.join(', ') unless manufacture_id.nil? f_product_type_id = "'#{product_type_id}'" conditions = ["'1'='1'"] conditions << "name LIKE #{f_name}" unless name.empty? conditions << "manufacture_id IN (#{f_manufacture_id})"# unless manufacture_id.nil? conditions << "product_type_id = #{f_product_type_id}" unless product_type_id.blank? #where("name LIKE ?", f_name).where(:manufacture_id => [manufacture_ids]) cond2 = conditions.join ' and ' # if f_name.nil? #and manufacture_id.nil? and product_type_id.blank? # find(:all) # else find(:all, :conditions => cond2, :order => 'id desc') # end end