I cannot get glyphicons to work with bootstrap 3 and rails. I've scowered the internet and nothing i find helps. In my bootstrap.css file i have:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('/assets/glyphicons-halflings-regular.eot');
src: url('/assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
In application.rb, I have:
config.assets.enabled = true
config.assets.paths << "#{Rails.root}/app/assets/fonts"
config.assets.precompile += %w( .svg .eot .woff .ttf )
I have already tried running:
rake assets:precompile RAILS_ENV=development
In application.js I have:
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require bootstrap
In application.css I have:
*= require_self
*= require_tree .
*= require bootstrap
*/
All my fonts are stored in assets/fonts
I've already looked at the following and none of them have worked:
Bootstrap 3+Rails 4 - Certain Glyphicons not working
How to add a custom font to Rails app?
How can I fix this?
I'll post my fix.
Because I previously precompiled my assets locally, then added glyphicons after, heroku was not picking up those assets. So I had to re-compile them locally again by doing:
And pushing to heroku
from heroku: https://devcenter.heroku.com/articles/getting-started-with-ruby#introduction
If you're using bootstrap-sass gem, follow my setup below. If not give it a try, it's the easiest bootstrap setup that I've used.
By the way I'm currently using rails Versions 4.1.6 and 4.1.8
Two gems
Your Application.js should look like this below (turbolinks optional)
Style sheet should have these two imports
if this setup doesn't work for you try font-path http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets
section 2.3.2 css and sass
so your code would go from:
to font-path('glyphicons-halflings-regular.eot');
Upgrading bootstrap gems, if you use them, fixed it for me:
gem 'sass-rails', '~> 5.0.1' gem 'bootstrap-sass', '~> 3.3.5.1'