Ricbermo
Ricbermo

Reputation: 805

html inside link_to rails is not working

I´m new with ruby and I´m trying to insert an awesome-font icon inside a link using rails 3.2.15

This is my code

<%= link_to tweet_path(tweet), method => :delete, :confirm => 'Are you sure?' do %>
    <i class="icon-trash"></i>
<% end %>

<%= link_to edit_tweet_path(tweet) do %>
     <i class="icon-pencil"></i>
<% end %>

I don´t know what I'm doing wrong.

Thank you in advance.

Upvotes: 0

Views: 68

Answers (2)

joseramonc
joseramonc

Reputation: 1921

you can do this:

<%= link_to content_tag(:i,nil, :class => "icon-trash"), tweet_path(tweet), method => :delete, :confirm => 'Are you sure?' %>

<%= link_to content_tag(:i,nil, :class => "icon-pencil"), edit_tweet_path(tweet) %>

hope this helps you

Upvotes: 1

Catfish
Catfish

Reputation: 19284

You can do this:

<%= link_to raw('<i class="icon-trash"></i>'), tweet_path(tweet), method => :delete, :confirm => 'Are you sure?' %>

Upvotes: 1

Related Questions