I am trying to use bootstrap 3 in my rails 4 app. Followed this tutorial to set up bootstrap 3 using bootstrap saas from this github page.
Bootstrap is working fine but glyphicons are not working as expected.
Certain glyphicons are not displaying at all. For e.g. I tired to display a few of them for testing in my application.html.erb:
glyphicon glyphicon-floppy-disk -> <span class="glyphicon glyphicon-floppy-disk"></span>
</br>
glyphicon glyphicon-plus -> <span class="glyphicon glyphicon-plus"></span>
</br>
glyphicon glyphicon-minus -> <span class="glyphicon glyphicon-minus"></span>
The icons render like this
The floppy-disk icon is not rendered at all (showing an invalid charecter) The plus and minus sigs are not bold and much smaller than the ones shown on the bootstap website.
I am also seeing the following messages on the rails console.
Started GET "/fonts/glyphicons-halflings-regular.woff" for 127.0.0.1 at 2014-02-22 16:29:54 -0800
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.woff"):
Started GET "/fonts/glyphicons-halflings-regular.ttf" for 127.0.0.1 at 2014-02-22 16:29:54 -0800
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.ttf"):
Started GET "/fonts/glyphicons-halflings-regular.svg" for 127.0.0.1 at 2014-02-22 16:29:54 -0800
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.svg"):
I would really appreciate your inputs on this issue.
Thanks!
Just use:
in your SCSS or SASS file. "bootstrap-sprockets" is required for image and font fix.
Chances are you already have:
declared in application.scss.
I was having trouble viewing:
in my development environment. The following adjustment worked.
In your css.scss file add:
I had the same problem and found a solution. Full credit goes to Eric Minkel, who wrote a detailed blog post on the topic. I would highly suggest reading it for further reasoning.
Edit
app/assets/stylesheets/application.css
by adding:Edit
app/assets/javascripts/application.js
by adding:In
config/application.rb
, add the following afterclass Application < Rails::Application
. It should look like this:In the terminal, compile your assets by running:
Edit the
bootstrap.css
file by changing@font-face
resource locations from../fonts/
to/assets/
. It should look like this:You're done. Just restart with
rails s
and the glyphicons should appear.Another solution would be copying the fonts folder into public so you have
The same solutions would work for font-awesome etc. The only downside of this is if you change your font-files often :o)
I had a similar problem and discovered an older version of the bootstrap assets were being served. Thanks to this post: Rails with Twitter Bootstrap: still serving an old asset I just ran
rake tmp:clear
and all worked after that.I was having this same problem. Solved by adding:
above the existing line:
in my /app/stylesheets/bootstrap_and_customisation.css.scss file