【发布时间】:2014-06-27 13:15:47
【问题描述】:
我是 ruby on rails 的新手,目前正在学习 Michael Hartl 的教程,不幸的是,当我尝试在 custom.css.scss 文件中调用 @import "bootstrap"; 时卡在了第五章。
我收到以下错误:
Sprockets::Rails::Helper::AssetFilteredError in StaticPages#home
Showing /Users/name/Documents/Rails_projects/sample_app/app/views/layouts /application.html.erb where line #5 raised:
Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( glyphicons-halflings.png )` to `config/initializers/assets.rb` and restart your server
(in /Users/name/Documents/Rails_projects/sample_app/app/assets/styleshee
/custom.css.scss)
Extracted source (around line #5):
line 5: stylesheet_link_tag "application", media: "all"
我已经在网上梳理了以下解决方案,但都没有奏效
- 上面为 assets.rb 文件提供的建议
- 使用 control+c 重启服务器
- 将 gem 文件“bootrap-sass”移动到 gem 文件中的部分 产品中不需要的资产
- 将 application.css 文件的扩展名更改为 应用程序.css.scss
- 直接调用@import “bootstrap”;在 application.css.scss 文件
- 在 config.ru 中添加以下内容:需要 'bootstrap-sass' #require bootstrap-sass 声明
这些都是我在网上找到的解决方案,但没有一个有效。
感谢任何帮助!
谢谢!
【问题讨论】:
-
您要添加什么版本的引导程序?
-
我正在使用 rails 4.1...
-
我的答案也应该适用于 rails 4.1
-
Wali Ali - 非常感谢!这似乎现在可以工作了,但是我在 custom.css 中调用什么来获取引导,因为我不再使用 @import 了?
-
不需要打电话。您创建一个扩展名为 .css 的文件。例如:custom.css(在 app/assets/stylesheets 内),然后您立即开始输入您的 css 代码。保存并刷新浏览器。也许也重新启动服务器(只是第一次)。它应该可以工作。
标签: css ruby-on-rails twitter-bootstrap