I am trying to get rid of the glyphicon errors in my Rails 4 project that's using Bootstrap 3. I'm not using any Bootstrap gems to add it to the asset pipeline. I manually added bootstrap.css and bootstrap.js to their respective app/assets
directories and added them to application.css
and application.js
What I'm seeing now is the following in my web browser's console:
GET http://localhost:3000/fonts/glyphicons-halflings-regular.woff 404 (Not Found) localhost/:1
GET http://localhost:3000/fonts/glyphicons-halflings-regular.ttf 404 (Not Found) localhost/:1
GET http://localhost:3000/fonts/glyphicons-halflings-regular.svg 404 (Not Found)
What can be done to fix this in a Ruby on Rails application? I tried copying said files to app/assets/fonts
and popped this into application.rb
:
config.assets.paths << "#{Rails}/app/assets/fonts"
No luck.
All solutions provided above are dirty hacks. The correct way to solve this issue is to include "bootstrap-sprockets" before bootstrap in your sass files:
Add the woff, ttf and svg files to:
Create this if it doesn't exist. They should be present in the build of bootstrap you downloaded.
Also, you'll need to add this to your application.css after all your require statements:
To get the glyphicons working I had to add a line to the config/application.rb file. Add the following within class Application < Rails::Application.
Then at the terminal run the command to get the assets to compile:
Now we need to update the bootrap.css file (you’ll likely need to update the bootstrap.min.css file as a result, too), search for @font-face with your text editor and update the paths to the font urls to include /assets/glyphicons-halfings-regular.* (include the file extension).
This is what the url’s will be originally in the bootstrap.css file.
You want to change each of these resource locations to /assets/glyphicons-halfings-regular.* as shown below.
SOURCE: [Erik Minkel Blog]
Moving the fonts to the /app/public folder worked but didn't seem like the Rails way.
What worked for me was putting them in /app/assets/fonts and commenting this out in bootstrap.css:
Basically you should just import bootstrap
Problems appear when you import bootstrap components before
@import "bootstrap-sprockets";
Overrides should go after@import "bootstrap-sprockets";