Search code examples
ruby-on-railsmaterialize

How to use secondary-content with link_to helper in rails with materialize css


Hi everyone i wish to add/span an icon inside a link_to block using the materialized collection secondary-content class link in this example.

This is my code

<div class="collection">
<%=link_to "Name",resource_name_path, class: "collection-item  #{active? resource_name_path}" %> 
</div>

Here is the HTML example on the website

<li class="collection-item"><div>Alvin<a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>

Thanks


Solution

  • You can skip the anchor name in link_to and pass a block to do multiline stuff! :) Here's how:

    <%= link_to resource_name_path, class: "collection-item  #{active? resource_name_path}" do %>
      <i class="material-icons">Name/Alvin?</i>
    <% end %>
    

    Hope this helps :)