Tags generated by select2 not loading correctly

I use select2

to make my tags look better and I had a problem saving and loading those tags.

I have this field for tags:

<%= f.text_field :tag_list %>


And I am setting select2

in this field like this:

    tags: []
    tokenSeparators: [ ',' ]
    formatNoMatches: ->


As you can see, I am using a delimiter for the tags. While I am typing the tags, they are correctly separated by ",", but the problem is when I save this form and click on edit again, the tags are merged into one tag. For example:

  • Open the edit page
  • Start typing the tags "one", "two" and "three"
  • Tags are properly separated by ","
  • Click the button to save the content
  • Tags are stored separately in the database as they must
  • Click again to edit the same content.
  • Tags are displayed as if they were combined: "one two three"

If you then click Save again, the content will no longer connect to the old tags. it will only be associated with the one-two-three merged tag.

Any ideas why this is happening? Thank.


source to share

All Articles