select2-rails + act_as_taggable_on rails 4 issue

此生再无相见时 提交于 2019-12-02 09:33:02
Arief Rizky Ramadhan

It's working now. I did it with this code: https://stackoverflow.com/a/33035355/5081949

Here is my code now:

app/views/profiles/new.html.erb

<%= f.input :skill_list, input_html: { class: 'multiple-input', multiple: "multiple" }, collection: @profile.skill_list %>

app/assets/application.js

$(document).ready(function() {
  $('.multiple-input').each(function() {
    $(this).select2({
      tags: true,
      tokenSeparators: [','],
      theme: 'bootstrap',
      placeholder: 'Separated by comma'
      });
    });
});

also in apps/controllers/profiles_controller.rb I added strong params

def profile_params
  params.require(:profile).permit(:name, skill_list: [])
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!