0
I have an application for scheduling services and I’m not able to preempt a selectbox from the selection made in another. Explaining better: I have a selectbox with the services available and when I select a service, I want to fill the selectbox of professionals who have the same specialty of the selected service. In the professional class I have:
Professional class < Activerecord::Base belongs_to :specialty has_many :reservations...
in the Service class: class Service < Activerecord::Base belongs_to :specialty has_many :reservations
in the Reserve class:
class Reserva < ActiveRecord::Base
belongs_to :client belongs_to :servico belongs_to :professional
and in the view of new booking:
<%= 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 :servico, 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 professionals with the same specialty and fill the price field that has in the service. Can someone help me? Thank you.