select2 rails form sends nothing

2019-09-09 12:57发布

问题:

I'm stacked. I'm using select2 and acts_as_taggable to tag my order model. Here is a code

<div class="field">
<%= f.label :tag_list, "TAGS" %><br>
<%= f.select :tag_list, options_for_select([['Human', 'Hs'], ['Mouse', 'Mm'], ['Yeast', 'Sc']]),{},:multiple => true, :class =>"category" %>
</div>

And also script:

<script>
$(document).ready(function() {$(".category").select2(); });
</script>

All works fine without connecting script ( with select2) but if with, it looks like working good but it sends empty strings and after submitting you didn't get any tags here. Can anyone help?