简体   繁体   中英

using select2 gem with acts_as_taggable gem on rails

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" %>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM