Reputation: 14504
I want to but and just after the second loop.
Example I have:
<% kon.tags.each do |d| %>
<%= link_to d.name, tag_path(d.kategori.slug, d.slug) %>,
<% end %>
It outputs: link, link, link, link,
What I want is: link, link, link and link
Upvotes: 0
Views: 93
Reputation: 16960
Rails provides a helper for this (Array#to_sentence), so you can do:
<%= raw kon.tags.collect { |d| link_to d.name, tag_path(d.kategori.slug, d.slug) }.to_sentence %>
Although be careful if you're using raw for user input.
Upvotes: 2