move autocomplete controllers

This commit is contained in:
Pete Matsyburka committed 2024-03-23 23:52:50 +02:00
1 parent 077eab7005
commit 8bef75e570
7 files changed
+51 -55

No files matched your search

@@ -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