From 12944a1ca23d758efb472862b0150afcba2018ca Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 21 Jun 2020 20:59:49 +0200 Subject: [PATCH] return users ransack search distinct --- api/app/controllers/spree/api/users_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/app/controllers/spree/api/users_controller.rb b/api/app/controllers/spree/api/users_controller.rb index 9d02b8a26b5..3ef14787b54 100644 --- a/api/app/controllers/spree/api/users_controller.rb +++ b/api/app/controllers/spree/api/users_controller.rb @@ -1,6 +1,19 @@ # frozen_string_literal: true class Spree::Api::UsersController < Spree::Api::ResourceController + def index + user_scope = model_class.accessible_by(current_ability, :read) + if params[:ids] + ids = params[:ids].split(",").flatten + @users = user_scope.where(id: ids) + else + @users = user_scope.ransack(params[:q]).result + end + + @users = paginate(@users.distinct) + respond_with(@users) + end + private attr_reader :user