[英]Why doesn't bootstrap-sass work with Rails?
I've added bootstrap-sass to my gemfile. 我已将bootstrap-sass添加到我的gemfile中。 I've followed the instructions here https://github.com/twbs/bootstrap-sass . 我已按照https://github.com/twbs/bootstrap-sass上的说明进行操作。 Modifications have been made to the javascript/application.js.scss and stylesheet/application.css.scss files per the above link. 根据上述链接,已对javascript / application.js.scss和stylesheet / application.css.scss文件进行了修改。
When I try to view a new controller, I get this: 当我尝试查看新控制器时,得到以下信息:
Sass::SyntaxError in Test#index Showing /Users/myuser/Rails/myproject/app/views/layouts/application.html.erb where line #5 raised: Test#index中的Sass :: SyntaxError显示/Users/myuser/Rails/myproject/app/views/layouts/application.html.erb,其中第5行出现:
File to import not found or unreadable: bootstrap-sprockets. 找不到或不可读的导入文件:引导链轮。
*/ @import "bootstrap-sprockets"; * / @import“ bootstrap-sprockets”; @import "bootstrap"; @import“引导程序”;
I haven't added any bootstrap code to the Rails app yet. 我尚未向Rails应用程序添加任何引导代码。 It's a new Rails app with only the above modifications and one new controller. 这是一个仅具有上述修改和一个新控制器的新Rails应用程序。
I did run bundle install but it seemed to not install anything. 我确实运行了bundle install,但似乎没有安装任何东西。 The output was this: 输出是这样的:
Bundle complete! 捆绑完成! 13 Gemfile dependencies, 56 gems now installed. 13个Gemfile依赖项,现在安装了56个Gem。 Use
bundle show [gemname]
to see where a bundled gem is installed. 使用bundle show [gemname]
查看捆绑的gem的安装位置。
along with a bunch of Using
s. 以及一堆Using
s。 I did see these entries: 我确实看到了这些条目:
Using bootstrap-sass 3.3.5.1
Using bootstrap-sass 0.0.2
Any idea why I'm getting the above error? 知道为什么我会收到上述错误吗?
you got your files a bit wrong. 您的文件有点错误。
make sure you have 'app/assets/javascripts/application.js with the following content 确保您具有以下内容的“ 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 .
and 'app/assets/stylesheets/application.scss' with following 和“ 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";
pay attention to file names and extensions 注意文件名和扩展名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.