I’ve been beating my head on this seemingly simple problem all evening
and would appreciate any pointers.
I have an Admin model and an Assistant model, both subclasses of User,
and with a HABTM relationship to each other (admins have many
assistants, and one assistant may work for multiple admins).
I have a join table called admin_assistant with columns of admin_id
and assistant_id.
In the form to create an Admin, I have:
<%= f.collection_select(‘assistant_id’,
@assistants_list, :id, :name ) %>
While displays fine, but when the controller create action tries to
create the new Admin, I get:
Assistant expected, got String
The params have the ids for the selected assistants as an array of
strings:
“admin”=>{“name”=>“Joe S.”, “assistants”=>[“2”, “3”], …}
I’ve googled all over for this and it seems most people get this
because the column name doesn’t have _id, which I already have. But
none of the examples I could find used HABTM relationships – does
this technique not work with the join table? What am I missing here?
Thanks for any pointers you can provide.
Michael