I have an application for scheduling services and I'm not able to populate a selectbox from the selection made in another. Explaining better: I have a selectbox with the available services and when I select a service, I want to fill the selectbox of professionals who have the same specialty of the service selected. In the professional class I have:
class Professional < ActiveRecord :: Base belongs_to: specialty has_many: reservations ...
in class Service: class Service < ActiveRecord :: Base belongs_to: specialty has_many: reservations
in the Reserve class:
class Reserva < ActiveRecord::Base
belongs_to: client belongs_to: service belongs_to: professional
and in the new reservation view:
<%= simple_form_for @reserva, html: { multipart: true,
class: 'form-horizontal' } do |f| %>
<% = f.association: client, label: 'Client:', label_method:: name, value_method:: id% > <% = f.association: service, label: 'Service:', label_method:: name, value_method:: id% > <% = f.association: professional, label: 'Professional:', label_method:: name, value_method:: id% > <% = f.input: price, label: 'Price:', readonly: true% >
My idea is, when selecting the service, list the professionals with the same specialty and fill the price field that has in the service. can anybody help me? Thank you.