繁体   English   中英

为什么Bootstrap-Sass无法与Rails一起使用?

[英]Why doesn't bootstrap-sass work with Rails?

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

当我尝试查看新控制器时,得到以下信息:

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

找不到或不可读的导入文件:引导链轮。

* / @import“ bootstrap-sprockets”; @import“引导程序”;

我尚未向Rails应用程序添加任何引导代码。 这是一个仅具有上述修改和一个新控制器的新Rails应用程序。

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

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

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

Using bootstrap-sass 3.3.5.1
Using bootstrap-sass 0.0.2

知道为什么我会收到上述错误吗?

您的文件有点错误。

确保您具有以下内容的“ 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";

注意文件名和扩展名

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM