В моем приложении rails есть простые отношения has_many и own_to.Я использую simple_form и хочу динамически изменять параметры выпадающего меню в зависимости от значения, выбранного пользователем.
Модели
class Processor < ApplicationRecord
has_many :processor_bank_accounts
end
class ProcessorBankAccount < ApplicationRecord
belongs_to :processor
end
Входные данные формы
<%= simple_form_for [@customer, @transaction] do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :status, :collection => ["payment request"], include_blank: false %>
<%= f.input :processor, collection: @processors ,label_method: :name,value_method: :id,label: "Processor" , include_blank: false %>
<%= f.input :processor_bank_account, collection: @bank_accounts , label_method: :bank_name, value_method: :id, label: "Processor Bank Account" , include_blank: true %>
<%= f.input :tcurrency, collection: @currencies, include_blank: false, label: 'currency' %>
<%= f.input :amount, as: :decimal, label: 'amount' %>
</div>
<div class="form-actions text-center">
<%= f.button :submit, "Add transaction", class: "form-button"%>
</div>
<% end %>
Поэтому, по сути, мне нужно, чтобы выпадающий список processor_bank_account заполнялся на основе процессора, выбранного пользователем.В консоли это будет просто: ProcessorBankAccount.where (процессор: процессор).
Необходимо загрузить параметры с помощью JS и подумать, что мне нужно использовать JSON, но не уверен, куда идти дальше