Adding Icon to Rails Application

Adding icon to rails application

You can use Favicon Rails helper:

<%= favicon_link_tag %>

Or if you want another image than favicon.ico

<%= favicon_link_tag 'another_image.ico' %>

How to set shortcut icon in rails?

See doc:

<%= favicon_link_tag 'favicon.ico' %>

how to put icon in rails submit button

You can do this by using the button_tag instead:

<%= button_tag( :class => "button_green") do %>
Submit for Approval <i class="icon-share-alt icon-white"></i>
<% end %>

This will create a <button type="submit"></button> element with the icon and wordage inside. I've tested and it works. The default action for button_tag is to submit, so if you need a different action (like cancel for example), you can use the :type => "button" option to override the default submit behavior.

Edit: For Bootstrap 3, the icon class names have changed, so you would put

<span class="glyphicon-white glyphicon-share-alt white"></span>

Notice, there is no longer a special class for white icons. Just make a css class .white and put color: #fff;. Simple. You can use any color or text style you like, since the icons are now a font.

Related Question: Add Icon to Submit Button in Twitter Bootstrap 2, and How do I change Bootstrap 3's glyphicons to white?

Rails Font Awesome Icons

Use this.

<i class="fa fa-home" aria-hidden="true"></i>

If you ever want any icon just go Here and click on icon you want and it will give your HTML for that icon.

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

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


Related Topics



Leave a reply



Submit