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