问题
Im using select2-rails gem in my rails app. I found a problem here:
Problem in tag_list. As u see it starts with ["",...] what wrong. Because of this my tag_list became empty after submitting. Without select2 it works fine. Can any one help?
My erb code
<%= f.label :tag_list, "TAGS" %><br>
<%= f.select :tag_list, options_for_select([['Asst', 'As'], ['Mouse', 'Mm'], ['Yeast', 'Sc']]),{},:multiple => true, :class =>"category" %>
回答1:
There are two problems here: 1) the tag_list parameter is not permitted in your controller and 2)Select2 is returning an array to your controller. To solve this, in your controller permitted params, you should declare the tag_list param like this:
tag_lists: []
It must be in PLURAL.
You should take a look at Rails API regarding strong parameters.
来源:https://stackoverflow.com/questions/31994057/using-select2-gem-with-acts-as-taggable-gem-on-rails