Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: how to use fontawesome icon

I want to add fontawesome icon

<i class="fa fa-trash-o"></i> 

in place of "Destroy"

<%= link_to 'Destroy', post_path(post), method: :delete, data: { confirm: 'Are you sure?' } %> 
like image 458
user2993454 Avatar asked Dec 03 '22 21:12

user2993454


1 Answers

You can try

<%= link_to(
      content_tag(
        :i,
        nil, 
        class: 'fa fa-trash-o'
      ), 
      method: :delete, 
      data: { 
        confirm: 'Are you sure?' 
      } 
    ) 
%>

You can try with other things that aren't :i like :div and if you want text inside like <i>TEXT</i> you can try with the TEXT instead of nil, hope this helps you.

like image 123
joseramonc Avatar answered Jan 01 '23 13:01

joseramonc