Class: EdiDocumentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/edi_documents_controller.rb

Instance Method Summary collapse

Methods included from AuthentificationHelper

#accessible_company_ids_from_tenant_and_user, #application_mode_from_hostname, #current_company_id_from_accessible_company_ids, #current_tenant_from_user, #current_user_and_locale_from_token

Instance Method Details

#optionsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/edi_documents_controller.rb', line 5

def options
  query = params[:query] || ''
  document_direction = params[:document_direction]
  customer_options = EdiDocument
                     .select(:transaction_set, :document_name)
                     .where(document_direction: document_direction)
                     .where('transaction_set LIKE :query', query: "%#{query}%")
                     .order(:transaction_set)
                     .limit(20)

  render json: {
    data: customer_options
  }
end