Skip to content

Commit

Permalink
return users ransack search distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
hefan committed Jun 30, 2020
1 parent 08f6301 commit 12944a1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions api/app/controllers/spree/api/users_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 12944a1

Please sign in to comment.