Search code examples
cssruby-on-railsrubytagsacts-as-taggable-on

How to change tag font color?


Why is <%= raw averaged.tag_list.map { |t| link_to t.titleize, tagquantifieds_path(t) }.join(', ') %>'s font color staying black instead of changing like the rest of <%= %>?

How can we fix this? I'm sure its a simple answer I just couldn't find it on the web.

<div class="stats">
<ul>
<% @averaged_quantifieds.each do |averaged| %>

<% averaged.results.each do |result| %>
<% if result.good == true %>
<div class="green">

      <%= averaged.results.first.date_value.strftime("%b") %>:

      <%= raw averaged.tag_list.map { |t| link_to t.titleize, tagquantifieds_path(t) }.join(', ') %> 

      <%= averaged.results.first.result_value %>

      <%= averaged.metric %>

</div>

<% else %>
<div class="red">

      <%= averaged.results.first.date_value.strftime("%b") %>:

      <%= raw averaged.tag_list.map { |t| link_to t.titleize, tagquantifieds_path(t) }.join(', ') %> 

      <%= averaged.results.first.result_value %>

      <%= averaged.metric %>

</div>

<% end %>
<% end %>
<% end %>

Thanks for your help!


Solution

  • Because link_to is not styling, do this:

    for red:

    <%= raw averaged.tag_list.map { |t| link_to t.titleize, tagquantifieds_path(t), {:style=>'color:red;'}  }.join(', ') %> 
    

    for green:

    <%= raw averaged.tag_list.map { |t| link_to t.titleize, tagquantifieds_path(t), {:style=>'color:green;'}  }.join(', ') %>