0

I know that stackoverflow is filled with these question, but the solutions I find doesn't fix my problem, first of all it appears that all responses assume that you have installed some gem to use bootstrap (like bootstrap-sass) when the only thing I did was download it and put the content in the appropriate folders as explained here.

So half of the answer are to put these commands:

@import "bootstrap-sprockets"
@import "bootstrap"

In my scss or sass file (which I have not).

and the other half say that I have to change this:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/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');
}

for this:

@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');
}

Wich didn't work for me...

So, anyone have another solution?

Community
  • 1
  • 1
Patricio Sard
  • 2,092
  • 3
  • 22
  • 52

1 Answers1

0

So half of the answer are to put these commands

If you read the docs, you'll see that bootstrap advocates adding the @import "bootstrap" directive to your main SCSS/SASS file (probably application.scss), so yes you do need to include that in your main file:

#app/assets/stylesheets/application.sass
@import bootstrap

This will include the bootstrap.sass file in your main application.sass file, allowing you to reference the classes etc from it.

This is irrespective of any font issues etc. You'll do well to read up on the sprockets manifest directives for more information on how this works.


Fonts

For your font issue, you've got several problems.

  1. You only need one bootstrap gem
  2. You don't need to manually include its files anywhere (they're included in the gem)

I would strongly recommend using rails-assets to pull from the bootstrap repo directly (keeps things clean):

#Gemfile
source "https://rails-assets.org"

gem 'rails-assets-bootstrap', ">= 4.0.0.alpha.2" 

This will put all the appropriate bootstrap files on your system, which you'll then be able to reference through your asset pipeline:

#app/assets/stylesheets/application.sass
@import bootstrap

This should include all the fonts for you.

To make sure they work, you'll be best precompiling the assets for production mode:

$ rake assets:precompile RAILS_ENV=production
Richard Peck
  • 76,116
  • 9
  • 93
  • 147