为什么没有使用Rails的bootstrap-sass工作?

时间:2015-11-21 16:35:43

标签: css ruby-on-rails twitter-bootstrap bootstrap-sass

我已将bootstrap-sass添加到我的gemfile中。我已经按照https://github.com/twbs/bootstrap-sass中的说明操作了。根据上述链接对javascript / application.js.scss和stylesheet / application.css.scss文件进行了修改。

当我尝试查看新控制器时,我明白了:

  

Sass :: Test#index中的SyntaxError显示   /Users/myuser/Rails/myproject/app/views/layouts/application.html.erb   第5行引出的地方:

     

要导入的文件未找到或不可读:bootstrap-sprockets。

     

* / @import" bootstrap-sprockets&#34 ;; @import" bootstrap&#34 ;;

我还没有将任何引导代码添加到Rails应用程序中。它是一个新的Rails应用程序,仅具有上述修改和一个新控制器。

我确实运行了bundle install,但似乎没有安装任何东西。输出是这样的:

  

捆绑完成! 13个Gemfile依赖项,现在安装了56个宝石。使用   bundle show [gemname]查看捆绑宝石的安装位置。

以及一堆Using个。我确实看到了这些条目:

Using bootstrap-sass 3.3.5.1
Using bootstrap-sass 0.0.2

我知道为什么会出现上述错误?

1 个答案:

答案 0 :(得分:0)

你的文件有点不对劲。

确保您拥有包含以下内容的'app / assets / javascripts / 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.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap-sprockets
//= require_tree .

和'app / assets / stylesheets / application.scss'及以下

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 */
@import "bootstrap-sprockets";
@import "bootstrap";

注意文件名和扩展名