简体   繁体   English

如何在Rails应用程序中用自定义图标替换字体真棒图标

[英]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. 我的Rails应用程序中有此代码,它会根据用户选择该项目的方式显示一个很棒的字体图标。

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. 您可以使用rails image_tag帮助器。 As long as its within the images folder so the asset pipeline knows where to look you could use 只要它在images文件夹中,资产管道就可以知道要查找的位置

<%= 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 1-第一种方法在您的项目中添加此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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