AnthonyGalli.com
AnthonyGalli.com

Reputation: 2866

How to keep comma between tags in _form?

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 :-]

Upvotes: 1

Views: 69

Answers (2)

Akshay Borade
Akshay Borade

Reputation: 2472

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.

Upvotes: 2

Jason Adrian Bargas
Jason Adrian Bargas

Reputation: 254

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

Upvotes: 1

Related Questions