2016-04-24 47 views
1

我无法弄清楚如何将wrap bootstrap文件集成到我的Rails 4应用程序中。Rails 4 - 供应商资产字体文件

我的供应商资产中有一个名为fonts的文件夹。

在这里面我有几个文件上被称为如下:

ActionController::RoutingError (No route matches [GET] "/assets/vendor/assets/fonts/Simple-Line-Icons.woff"): 

我我的供应商/资产/样式表,我有一个文件叫做简单线路icons.css,其中有:

@font-face { 
    font-family: 'Simple-Line-Icons'; 
    src:url('vendor/assets/fonts/Simple-Line-Icons.eot'); 
    src:url('vendor/assets/fonts/Simple-Line-Icons.eot?#iefix') format('embedded-opentype'), 
     url('vendor/assets/fonts/Simple-Line-Icons.woff') format('woff'), 
     url('vendor/assets/fonts/Simple-Line-Icons.ttf') format('truetype'), 
     url('vendor/assets/fonts/Simple-Line-Icons.svg#Simple-Line-Icons') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 

当我保存一切,预编译的资产,我的控制台错误日志显示:

Failed to load resource: the server responded with a status of 404 (Not Found) 
http://localhost:3000/assets/vendor/assets/fonts/Simple-Line-Icons.ttf Failed to load resource: the server responded with a status of 404 (Not Found) 

有人能看到什么ñ发生碰巧得到这个工作?

考虑下面的建议,我现在有:

@font-face { 
    font-family: 'Simple-Line-Icons'; 
    /*src:url('vendor/assets/fonts/Simple-Line-Icons.eot');*/ 
    src:asset-url("fonts/Simple-Line-Icons.eot"); 
    src:asset-url("fonts/Simple-Line-Icons.eot?#iefix") format('embedded-opentype'), 
    asset-url("fonts/Simple-Line-Icons.woff") format('woff'), 
    asset-url("fonts/Simple-Line-Icons.ttf") format('truetype'), 
    asset-url("fonts/Simple-Line-Icons.svg#Simple-Line-Icons") format('svg'); 

内简单线icons.css.erb

,但我仍然得到404错误

回答

2

添加.erb到结束你的css文件,然后将url('vendor/assets/fonts/Simple-Line-Icons.eot')更改为asset-url("fonts/Simple-Line-Icons.eot"),并与其他文件相同。我认为问题出在您预编译文件之后,rails会为该文件添加一个随机标记,例如"/assets/application-908e25f4bf641868d8683022a5b62f54.js",所以如果您使用的是'vendor/assets/fonts/Simple-Line-Icons.eot',则无法找到该文件。

更新

改变你的simple-line-icons.css.erb文件simple-line-icons.scss然后

@font-face { 
    font-family: 'simple-line-icons'; 
    src: asset-url('Simple-Line-Icons.eot?v=2.2.2'); 
    src: asset-url('Simple-Line-Icons.eot?v=2.2.2#iefix') format('embedded-opentype'), asset-url('Simple-Line-Icons.ttf?v=2.2.2') format('truetype'), asset-url('Simple-Line-Icons.woff2?v=2.2.2') format('woff2'), asset-url('Simple-Line-Icons.woff?v=2.2.2') format('woff'), asset-url('Simple-Line-Icons.svg?v=2.2.2#simple-line-icons') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 

在你application.css文件末尾添加如下内容:

*= require simple-line-icons 

因为很显然require_tree。将不需要在你的供应商和lib文件夹中的文件

+0

嗨,我试过了,并显示在上面的尝试。我仍然在文件上收到404错误 – Mel

+0

您是否处于生产模式或开发模式下? –

+0

开发模式 – Mel

相关问题