Class: Uchi::BelongsTo::AssociatedRecordsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/uchi/belongs_to/associated_records_controller.rb

Overview

Companion controller for the Stimulus-based belongs_to_controller.

Provides backend support for fetching associated records for a belongs_to field via AJAX.

Instance Method Summary collapse

Instance Method Details

#indexObject



14
15
16
17
18
19
# File 'app/controllers/uchi/belongs_to/associated_records_controller.rb', line 14

def index
  @current_value = field.value(parent_record)

  @field_name = params[:field]
  @records = field.collection_query.call(find_all_records_from_association)
end