move autocomplete controllers

This commit is contained in:
Pete Matsyburka
2024-03-23 23:33:42 +02:00
parent 077eab7005
commit 8bef75e570
7 changed files with 51 additions and 55 deletions
@@ -0,0 +1,14 @@
# frozen_string_literal: true
class TemplateFoldersAutocompleteController < ApplicationController
load_and_authorize_resource :template_folder, parent: false
LIMIT = 100
def index
template_folders = @template_folders.joins(:templates).where(templates: { archived_at: nil }).distinct
template_folders = TemplateFolders.search(template_folders, params[:q]).limit(LIMIT)
render json: template_folders.as_json(only: %i[name archived_at])
end
end