has and belongs to many - Rails 3 collection_select helper method for a HABTM relationship -
i have 2 models, sessions , presenters habtm relationship between them. on create session page, provide drop down box user may select multiple presenters session. code in _form.html.erb (for sessions) is
<%= f.label :presenters %>
<%= collection_select(:session, :presenters, presenter.all, :id, :name,{:include_blank => ''},{:multiple => true})%>
however on hitting create following error message on browser: presenter(#2176431740) expected, got string(#2151988680)
the request log shows "presenters"=>["1","2"]
i guessing array of strings containing ids of selected presenters being returned instead of presenter objects. cannot understand how work.
(ps- have created presenters_sessions table , specified has_and_belongs_to_many in both models)
thanks in advance.
i haven't figured out, work if pass in :presenter_ids second parameter rather :presenters. in end, mapping selected ids model's id collection. error saying "you tried assign string collection of presenters".
Comments
Post a Comment