seyhunak / twitter-bootstrap-rails

Twitter Bootstrap for Rails 6.0, Rails 5 - Rails 4.x Asset Pipeline
https://github.com/seyhunak/twitter-bootstrap-rails
4.49k stars 997 forks source link

Glyph not working with Bootstrap 3 + Rails 4 #733

Closed nosolopau closed 10 years ago

nosolopau commented 10 years ago

Hi :)

I'm trying to use glyphicons in my app, using the bootstrap3 branch and Rails 4.1. I've edited my bootstrap_and_overrides.css (I'm using the gem with 'plain css', no with less) to set: =require twitter-bootstrap-static/sprites.

And when I load the views, I can see some 404 errors:

captura de pantalla 2014-05-04 a la s 16 39 38

I see that the URL for the assets is something like http://localhost:3000/assets/fonts/glyphicons-halflings-regular.svg. (note the assets/fonts part). If I point the browser to http://localhost:3000/assets/glyphicons-halflings-regular.svg then I can download the file.

I've reviewed all the issues mentioning similar problems, but I can't find a solution. Any suggestion or idea will be very appreciated :).

panmari commented 10 years ago

Same here. They do get precompiled, but they are not correctly referenced with digest (as seen above in your picture)

panmari commented 10 years ago

I fixed it by compiling the assets specifically for production mode

RAILS_ENV=production rake assets:precompile

This fixed the issue for me.

take commented 10 years ago

Overriding the font's location by adding the following to application.css worked for me

/* Override Bootstrap 3 font locations */
@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('../assets/glyphicons-halflings-regular.woff') format('woff'),
  url('../assets/glyphicons-halflings-regular.ttf') format('truetype'),
  url('../assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

The tip was written in http://www.erikminkel.com/2013/09/01/twitter-bootstrap-3-in-a-rails-4-application/ 's comment section.

I guess the value of asset_path is wrong...?

toadkicker commented 10 years ago

We comment out glyphicons and use fontawesome as the default. It is included around L#17 commented out.

If you are using Bootstrap 2.1:

// Glyphicons
//@import "twitter/bootstrap/sprites.less";

If you are using Bootstrap 3.0+:

// Glyphicons
//@import "twitter/bootstrap/glyphicons.less";
waiting-for-dev commented 10 years ago

And what about if less is not being used?

toadkicker commented 10 years ago

We don't support SASS.

waiting-for-dev commented 10 years ago

No, I'm trying to use the static mode.

toadkicker commented 10 years ago

@take's paths should work then, the static option just means you're using a standard CSS @import statement with the correct path set.

waiting-for-dev commented 10 years ago

Mmm, yeah, it is true, but for some reason paths are being recognized in the app but not in integration tests...

toadkicker commented 10 years ago

https://github.com/seyhunak/twitter-bootstrap-rails/pull/802 would fix it as well, you're welcome to try that branch. I got rid of the static option all together because it caused the gem to be cluttered with paths to bootstrap.

waiting-for-dev commented 10 years ago

Oh, ok, I didn't know the static branch was someway being deprecated. Many thanks for your help :)

toadkicker commented 10 years ago

Thee static branch became an install option in 2.7, but we then started getting PR's where there was a new version of Bootstrap/Fontawesome for the LESS install but not the static versions or vice-versa. It's better we just manage it with bower internally because it takes the human error out of the equation. Give that branch a try, it's a major change, needs some good testing in the wild.