Damir Nurgaliev
Damir Nurgaliev

Reputation: 361

using select2 gem with acts_as_taggable gem on rails

Im using select2-rails gem in my rails app. I found a problem here:enter image description 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" %>

Upvotes: 0

Views: 171

Answers (1)

Diego Senott
Diego Senott

Reputation: 176

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.

Upvotes: 1

Related Questions