简体   繁体   中英

Ruby On Rails Bootstrap glyph icons not working properly

For some reason my Application isn't finding my glyph-icons in my Aseets folder. This is the message that I'm receiving

ActionController::RoutingError (No route matches [GET] "/assets/images/glyphicons-halflings.png"):

I'm sorry if this is a stupid question and or it's already been answered, I'm fairly new to rails and I just can't seem to figure it out.

It depends on what you are using. Try adding this to your application.css.scss or whatever file you are using to override some bootstrap stuff.

[class^="icon-"], [class*=" icon-"] {
  background-image: url(/assets/glyphicons-halflings.png)
}

My guess is that it's not searching in the right location. So figure out where it is and then just direct the link there.

If your view code called /assets/images/glyphicons-halflings.png, it would look for them in that absolute path. Posting your view code and your application.js/application.css files would be helpful

well the default location of that file is in img. Are you sure it isn't in assets/img?

considering that the file is a sprite sheet i'm not sure why you're trying to load it in something like an image tag.

if you are trying to use the images like the bootstrap site advises you to do ( here ) you may need to go into your bootstrap.css file and edit the path that looks for the glyphicons-halflings.png file. the default path is "../img/glyph.png" which would probably be stopping your images to show up (if thats what you're trying to do)

There are many right answers. But to fix this problem you should do the followings:

  1. go tot he public folder (not the asset)
  2. create a folder call img
  3. place your graphicons in that folder

that should work

I ran into this problem while trying to use a manually installed version of 2.3.2 bootstrap. In the bootstrap.css file it, if you CTRL / command + F for 'glyphicon', you will see that it will be looking for url(../img/glyphicons-halflings.png)

You need to change the two found instances to url(/assets/glyphicons-halflings.png)

I tried changing the original (../img/glyph...) to many things, only /assets/glyph... worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM