OSDN Git Service

Remove duplicate items from search autocomplete
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Mon, 9 Dec 2013 14:26:43 +0000 (16:26 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Mon, 9 Dec 2013 14:26:43 +0000 (16:26 +0200)
Old behaviour gave you duplicate entries if your project is public

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/helpers/search_helper.rb

index 8ff0bc6..109acfd 100644 (file)
@@ -8,7 +8,9 @@ module SearchHelper
       default_autocomplete,
       project_autocomplete,
       help_autocomplete
-    ].flatten.to_json
+    ].flatten.uniq do |item|
+      item[:label]
+    end.to_json
   end
 
   private