Rails acts_as_taggable, tags losing comma on edit!? becomes one
Asked Answered
A

2

16

I am using acts_as_taggable_on gem with Rails 4.2 and I have a form where you can enter tags, seperated by commas.

<div class="form-group">
  <%= f.label(:tag_list, "Tags (seperated by commas)") %><br />
  <%= f.text_field(:tag_list, :class=>"formbox")%>
</div>

The tags work fine, but when I go back to an article and edit it, the commas that were previously there disappear! For example, if I input tags:

white, light, soft

When I edit, those 3 separate tags will become 1 tag:

white light soft

Does anybody know what's happening here? It sucks to lose all those tags, I want to be able to keep all those tags upon edit.

Apache answered 28/2, 2015 at 20:1 Comment(2)
Doing a 5 minute-research I found this: github.com/mbleigh/acts-as-taggable-on/issues/620 . Maybe google first next time? :D You might have found this.Eustis
Possible duplicate of Rails 4: text_field for acts_as_taggable_on not separating tags with a commaServile
L
13

simple_form:

<%= f.input :tag_list, :label => "Tags* (seperated by commas)", :input_html => { :class => "css-class", :value => @article.tag_list.join(", ") } %>
Limiting answered 16/7, 2015 at 19:15 Comment(0)
C
0

There is a workaround for this by adding "," between each tag item. Which can be done like this:

<div class="form-group">
      <%= f.label(:tag_list, "Tags* (seperated by commas)") %><br />
      <%= f.text_field(:tag_list, value: @article.tag_list.join(","))%>
</div>
Carbonous answered 28/2, 2015 at 20:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.