Has anyone else run into the need for has_many :through accessor
methods? For example, say you have Users and Groups joined through
Membership. I would like a multiple select on the edit User page to
choose which Groups he or she is part of. I also want a similar select
on the Group page to choose which Users to include.
Ideally I could just have a collection_select on the edit page but this
doesn’t work for a number of reasons. First there needs to be
User#groups= and Group#users= methods. Second, the select itself needs
to be hacked up to work properly. Lastly, there needs to be some checks
at the controller level. This is because if all Groups were deselected,
nothing would pass through. In some cases this would imply removing the
User from all Groups.
I’ve come up with an okay solution and put up some sample code here
I want to generalize the solution because it’ll clean up my app
significantly. Is anyone working on something similar?