2016-04-24 65 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

相關問題