In order to implement dynamic select menus, I would like to produce two
group select inputs. Both have problems.
The form is for the model treatment. and medicine (many to many through a
join with a model medicine). There is a schedule
1. Treatment has a field schedule (string). I want to populate the dropdown
with the schedule.name from the schedule model group by schedule.type
- Schedule is a separate unrelated model.
- All online examples seem to group based on a relationship.
- <%= f.input :schedule, :collection => Schedule.all, :as =>
:grouped_select, :group_method => :type %> give an error undefined method
`map' for string
2. Treatment has a field for medicine ; joined many to many through
TreatmentMedicine. Medicines also have a type attribute.
- How do I create a multiselect for medicines grouped by medicine.type
(through this join),
I know these questions require some thought. Any help would be much