Muhammad_Sigit_Dude
Muhammad_Sigit_Dude

Reputation: 77

What's the easiest way to add font-awesome in rails 4

I have followed the instructions from font awesome guide at http://fortawesome.github.io/Font-Awesome/get-started/ but the font doesn't appear to my html.erb page, instead it shows weird symbols.

Upvotes: 0

Views: 436

Answers (3)

Igor Ivancha
Igor Ivancha

Reputation: 3451

in your config/initializers/assets.rb add next strings:

Rails.application.config.assets.precompile += %w( fontawesome-webfont.eot )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.woff2 )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.woff )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.ttf )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.svg )

in your app/assets/stylesheets/application.css add

*= require font-awesome

Upvotes: 0

Marcus Ilgner
Marcus Ilgner

Reputation: 7211

Personally I like the font-awesome-rails gem best. It integrates FA into the asset pipeline and adds a fa_icon helper that you can use in your views.

Upvotes: 1

margo
margo

Reputation: 2927

What code are you using for your classes? You need to use 'fa', not 'icon' e.g.

class="fa fa-plus"

Upvotes: 0

Related Questions