I have created an associated models to create a check box list, where user can select languages that he/she speaks. I have tried to use both Chosen and Select2 but could not make it work. The problem might be because I use check_box_tag
Here is my code;
<%= hidden_field_tag "user[language_ids][]", nil %>
<% Language.all.each do |language| %>
<%= check_box_tag "user[language_ids][]", language.id, @user.language_ids.include?(language.id), id: dom_id(language) %>
<%= label_tag dom_id(language), language.name %> </br>
<% end %>
I have watched the Railscast Habtm video to create this. This just works fine but I would like to make it user friendly. Thank you
You need to render a
<select>
tag instead of checkboxes:then you can call
$(..).select2()
on that DOM element