ruby-on-railsclassbootstrap-4stylesacts-as-taggable-on

Add Bootstrap style to individual tags in Acts_as_taggable_on tag_list


I am using the "acts as taggable on" gem and it's working perfectly. The issue I'm having is trying to add a css class style the individual tags in the list.

I have the code below but it applies the bootstrap pill style to the entire list as one giant pill rather than each specific tag. I have tried applying it to the "t" in the loop but its not working. Any help would be appreciated.

<%= raw article.tag_list.map { |t| link_to t, tag_path(t) }.join(', ') %>

here is what this is showing.

enter image description here


Solution

  • The code you added in the example is not showing any class added to the li or ul tags... not sure how you get the result in your screenshot.

    But if you meant pills like this in bootstrap 4, please try this:

    <%= article.tag_list.map { |t| link_to(t, tag_path(t), class: 'badge badge-primary') }.join(', ') %>
    

    Not sure you need a raw also, but as I haven't seen your code, I let you judge of that.

    I hope this helps!