2015-10-09 54 views
0

我安裝了bootstrap-sass Gem並試圖使用一些圖形,但它們只是沒有以正確的方式顯示。它看起來像瀏覽器正在使用替代實際glyphicons,但它不會給我任何錯誤消息。Rails 4中的bootstrap-sass沒有顯示正確的圖形

對於大多數glyphicons我只是得到這一個: 和鉛筆例如我得到這個。它看起來像瀏覽器無法找到它們,但我的樣式表正在正確加載,據我所知。那麼,我可能需要解決寶石中的問題嗎?

我的代碼如下所示:

application.css.scss

/* 
*= require jquery-ui 
*= require_tree . 
*= require_self 
*/ 

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

的application.js

//= require jquery 
//= require jquery_ujs 
//= require jquery-ui 
//= require bootstrap-sprockets 
//= require moment 
//= require jquery_nested_form 
//= require turbolinks 
//= require ckeditor/init 
//= require_tree . 

index.html.erb

<%= link_to booking_path(booking), :class => 'btn btn-xs', :title => "#{ t('.show', :default => t('helpers.links.show')) }" do %> 
    <%= glyph 'info-sign' %> 
<%- end -%> 

如果您需要更多信息,請讓我知道。

EDIT1:

我的代碼創建下面的HTML:

<a class="btn btn-xs" title="Show" href="/houses/1"> 
    <span class="glyphicon glyphicon-info-sign"></span> 
</a> 
+0

什麼是呈現的html:<%= glyph'info-sign'%>? –

+0

用html編輯主帖。 – Syk

回答

1

指定軌道-sass.gem的寶石版本和引導,sass.gem它之後終於有效了。

gem 'bootstrap-sass', '~> 3.3.5.1' 
gem 'sass-rails', '~> 5.0.1' 
0

bootstrap-sass文檔,你必須remove *= require_self和你application.css.scss*= require_tree

然後,刪除所有* = require_self和* = require_tree。語句 來自sass文件。相反,使用@import導入Sass文件。

請勿在Sass中使用* = require,否則您的其他樣式表將不能使用 訪問Bootstrap組合變量或變量。

所以,你可以使用@import

application.css.scss

/* 
*= require jquery-ui 
*/ 

@import "bootstrap-sprockets"; 
@import 'bootstrap'; 
+0

謝謝你的嘗試。雖然沒有帶來任何改變。 – Syk

+1

你有字體glypicon嗎?請這樣做http://stackoverflow.com/questions/20255711/ruby-on-rails-bootstrap-glyphicons-not-working。我希望這可以幫助你 – akbarbin

+0

我看到這個線程已經試過了,但我不確定它應該如何完成。我所有的樣式表都通過資產管道加載。所以我在gem目錄中搜索了特定的部分,但是我找不到100%適合的代碼。我所能找到的是'_bootstrap.scss',它正在加載'_glyphicons.scss'。在該文件中,字體路徑被描述爲'$ icon_font_path',如果我正確理解了gem文檔,那麼應該是OK:'$ icon-font-path默認使用引導程序/如果使用資源路徑助手,並且../fonts/引導/否則.' – Syk