简体   繁体   中英

How to replace font awesome icons with custom icons in rails application

I have this code in my rails app, it displays a font awesome icon depending on wheteher the user selected the item.

My question is can I replace the font awesome icon with a custom icon from my assets/image file, if so I would appreciate if anyone could show me how to do this.

    <li class="<%= 'fa fa-times' if !@room.is_tv %>"> Cable TV</li>

You could use a rails image_tag helper. As long as its within the images folder so the asset pipeline knows where to look you could use

<%= image_tag('name-of-img.png') %>

EDIT from comments:

<% if !@room.is_tv %>
  <li>
    <%= image_tag('sign.png') %>
  </li>
<% end %>

From what you put in the comments

 <li><img src="<%= asset_path 'sign.png' if !@room.is_tv %>">TV</li>
                                                              ^This part is whats rendering text

try to add new icons with

  • 1- first method add this link in you projet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM