From 7646504cde70fdf16b2f3fd956f97e2d728905a7 Mon Sep 17 00:00:00 2001 From: sean Date: Sun, 6 Mar 2011 13:59:02 -0800 Subject: [PATCH] Fixes issue where the same value in the field was being returned multiple times and then later only the unique values were being shown in the div. --- lib/auto_complete.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/auto_complete.rb b/lib/auto_complete.rb index 4afc7c2..a0f7f71 100644 --- a/lib/auto_complete.rb +++ b/lib/auto_complete.rb @@ -33,6 +33,7 @@ module ClassMethods def auto_complete_for(object, method, options = {}) define_method("auto_complete_for_#{object}_#{method}") do find_options = { + :select => "DISTINCT(#{method})", :conditions => [ "LOWER(#{method}) LIKE ?", '%' + params[object][method].downcase + '%' ], :order => "#{method} ASC", :limit => 10 }.merge!(options) @@ -44,4 +45,4 @@ def auto_complete_for(object, method, options = {}) end end -end \ No newline at end of file +end