Ajaxify booth responsibles selectize interface

No need to load *all* users into a select input...
This commit is contained in:
Henne Vogelsang 2022-02-16 14:07:23 +01:00
parent 800bb28c34
commit 2e21079991
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
4 changed files with 77 additions and 29 deletions

View file

@ -1,6 +1,7 @@
# frozen_string_literal: true
class UsersController < ApplicationController
before_action :authenticate_user!, only: :search
load_and_authorize_resource
# GET /users/1
@ -22,6 +23,14 @@ class UsersController < ApplicationController
end
end
def search
respond_to do |format|
format.json do
render json: { users: User.where('username like ?', "%#{params[:query]}%").select(:username, :id) }
end
end
end
private
# Only allow a trusted parameter "white list" through.