本文介绍了Rails 4.1和Bootstrap 3 glyphicons不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图摆脱我的Rails 4项目中使用Bootstrap 3的glyphicon错误。我没有使用任何Bootstrap gems将它添加到资产管道。我手动将bootstrap.css和bootstrap.js添加到它们各自的 app / assets 目录中,并将它们添加到 application.css application.js 我现在看到的是我的web浏览器控制台中的以下内容:

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)

在Ruby on Rails应用程序中可以做什么来解决这个问题?我尝试将所述文件复制到 app / assets / fonts ,并将其弹出到 application.rb

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"

没有运气。

推荐答案

上面提供的所有解决方案都是肮脏的黑客。解决这个问题的正确方法是在引导之前在你的sass文件中包含bootstrap-sprockets:

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:

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

这篇关于Rails 4.1和Bootstrap 3 glyphicons不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 04:22