How to keep comma between tags in _form?

99 views Asked by At

For some reason my commas keep disappearing whenever I go to edit the _form, which means if I resubmit the _form now all the tags in that _form are combined into one big, ugly tag :/

I have this line in my _form <%= f.text_field :tag_list %>

I closely followed this railscast tutorial: railscasts.com

Can anyone figure out off hand what might be the problem here? I don't even know what other code to add here that would be helpful.

Please let me know if you need further explanation or code to help you help me :-]

2

There are 2 answers

0
Akshay Borade On BEST ANSWER

Try this .......

<%= f.text_field :tag_list,  :id => "tags", :value => @your_var.tags.map(&:name).join(',') %>

Hope, I understand the question correctly and this solution will help you.

3
Jason Adrian Bargas On

If I understand the question correctly, just use join(', ') on your tag_list :)