change count>0 to exists

This commit is contained in:
junwen yang
2017-08-23 22:54:51 +00:00
parent 868c489d5e
commit 8124f26a6e
4 changed files with 4 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ class DirectoryItemsController < ApplicationController
user_ids = UserSearch.new(params[:name]).search.pluck(:id)
if user_ids.present?
# Add the current user if we have at least one other match
if current_user && result.dup.where(user_id: user_ids).count > 0
if current_user && result.dup.where(user_id: user_ids).exists?
user_ids << current_user.id
end
result = result.where(user_id: user_ids)