来自\ app \ views \ layouts \ application.html.erb:
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
&#13;
的application.js:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require turbolinks
//= require_tree .
&#13;
如何加载Bootstrap样式?
答案 0 :(得分:0)
似乎缺少导入引导程序样式。要根据bootstrap-sass
documentation解决此问题,您应该:
在app/assets/stylesheets/application.scss
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
必须在引导程序之前导入bootstrap-sprockets才能使图标字体生效。
确保文件的扩展名为.scss(或Sass语法为.sass)。如果你刚刚生成了一个新的Rails应用程序,它可能会附带一个.css文件
答案 1 :(得分:0)
首先,您应该决定使用哪个宝石,twitter-bootstrap-rails
或bootstrap-sass
,而不是两者。
假设您使用bootstrap-sass
,那么application.js
应该
//= require bootstrap-sprockets
不是
//= require twitter/bootstrap
然后添加
@import "bootstrap-sprockets";
@import "bootstrap";
到你的app/assets/stylesheets/application.scss
R. Sierra说。
现在你的应用程序应该不错!