Skip to content

Instantly share code, notes, and snippets.

@ugisozols
Forked from markoh/gist:1418917
Created December 1, 2011 18:49
Show Gist options
  • Save ugisozols/1418934 to your computer and use it in GitHub Desktop.
Save ugisozols/1418934 to your computer and use it in GitHub Desktop.
def self.search_filter(name,manufacture_id,product_type_id)
f_manufacture_id = manufacture_id
f_manufacture_id = f_manufacture_id.join(', ') unless manufacture_id.nil?
result = order("id DESC")
result = result.where("name LIKE ?", "%#{name}%") unless name.empty?
result = result.where("manufacture_id IN (?)", f_manufacture_id) unless manufacture_id.nil?
result = result.where(:product_type_id => product_type_id) unless product_type_id.blank?
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment