tiktak
tiktak

Reputation: 1811

twitter-bootstrap-rails gem: font awesome support

According to the changelog twitter-bootstrap-rails gem supports font awesome since v.2.0.9. So how to turn on this support in project? Font awesome icons are not available for me by default.

Upvotes: 1

Views: 5024

Answers (4)

Duany Dreyton
Duany Dreyton

Reputation: 176

You can add icons to your HTML code, like this:

<i class="icon-search"></i>

However, if you want place icons in Rails link_to helper use the ilink_to helper method. Follow the steps below:

1) Add the gem to your assets group in the Gemfile: gem 'less-rails-fontawesome'

2) Run bundle install:

3) Be sure that @import 'fontawesome'; is uncommented in app/assets/stylesheetes/bootstrap_and_overrides.css.less.

4) Use *ilink_to* helper instead of *link_to* helper.

<%= ilink_to "upload-alt", "Edit", edit_post_path(post), class: 'btn btn-mini' %>

Obs: Precede the link text with the icon name stripped off icon- prefix

These instructions are here: https://github.com/wbzyl/less-rails-fontawesome

Upvotes: 1

Pavel Nikolov
Pavel Nikolov

Reputation: 9541

The twitter-bootstrap-rails gem has more dependencies since twitter bootstrap css uses LESS. In order to turn font-awesome on in your project you need to add

gem 'less-rails'

gem 'therubyracer'

in the :assets group of your Gemfile. After that you are able to use it in your project.

Upvotes: 2

denis.peplin
denis.peplin

Reputation: 9841

It is now supported in twitter-bootstrap-rails by default.

Just add icons into your html code, like this:

<i class="icon-refresh"></i>

More icons and examples here: http://fortawesome.github.com/Font-Awesome/

Upvotes: 3

merv
merv

Reputation: 76760

See the Using Font Awesome wiki page in their GitHub project. It is more recent than the v2.0.9 release, so I assume it is the current recommended practice.

Upvotes: 1

Related Questions