Bootstrap 3.0 gives you access to the awesome icon set icon set by these dudes but it's not obvious for a Rails newbie like myself to get it all working together nicely
-
Download the bootstrap-glyphicons.css from here. Save that file to
RAILS_ROOT/vendor/assets/stylesheet/bootstrap-glyphicons.css
-
Save all the font files in
/dist/fonts
from the Bootstrap 3.0 download to a new folder in your Rails appRAILS_ROOT/vendor/assets/fonts
-
Add this folder to the asset pipeline by appending
config.assets.paths << Rails.root.join("vendor","assets", "fonts")
toapplication.rb
after the line that hasclass Application < Rails::Application
. -
In
bootstrap-glyphicons.css
modify the theurl
paths in@font-face
to read/assets/FILE_NAME
instead of../fonts/FILE_NAME
Example:
src:url('../fonts/glyphicons-halflings-regular.eot');
becomes
src:url('/assets/glyphicons-halflings-regular.eot');
There are only about 5 times in the file where you have to do this and they are all on the same line (~ line 63).
-
Beer me.
Now you can kick icons around like you're Messi or something. Try adding <span class="glyphicon glyphicon-search"></span>
to an html page and bask in the glory of icons. Or don't. Your call.
Ok - this works but I'm honestly confused as to why it works. When loading the site with asset compile turned off (as it should be in production) the bootstrap path to the font files is like this:
font-family:'Glyphicons Halflings';src:url(/assets/glyphicons-halflings-regular.eot)
That path does not exist. The glyphicons-halflings-regular.eot file exists under /public/assets/ but with the compiled name, ie glyphicons-halflings-regular-0f3d15597eadce7b61d56v4a4dr36e0b.eot
How is rails figuring out where to serve this file from as the path in the css file isn't even valid?
Thanks!