【发布时间】:2014-05-08 19:27:39
【问题描述】:
我的资产管道一直有问题,即使在阅读http://guides.rubyonrails.org/asset_pipeline.html之后我仍然遇到问题。
当我在开发中加载页面时,我的 css 没有呈现,看起来 css 没有被考虑在内,因为如果我将此 css 放入页面标题中的<script></script> home.html .erb 完美运行。
我在 app/assets/stylesheets/bootstrap.css.scss
中有这个样式表bootstrap.css.scss
/* BOOSTRAP CSS */
/* /BOOSTRAP CSS */
.form-group {
width: 250px;
font-size: 10px;
opacity: 1;
}
.panel {
width:300px;
margin-left: auto;
margin-right: auto;
opacity: 0.8;
z-index: 10000;
}
.btn-default {
border: 1px solid #28c3ab;
color: #1abc9c;
background-color: #f1c40f;
}
.jumbotron {
background-color:#ecf0f1;
color:#1abc9c;
}
.btn-default {
color: #1abc9c;
background-color: #f1c40f;
}
.btn-default:hover,
.btn-default:focus {
border: 1px solid #28c3ab;
outline: 0;
color: #1abc9c;
background-color: #3498db;
}
.btn-primary {
border: 1px solid #28c3ab;
color: #f1c40f;
background-color: #1abc9c;
}
.btn-primary:hover,
.btn-default:focus {
border: 1px solid #28c3ab;
outline: 0;
color: #f1c40f;
background-color: #3498db;
}
这是我在 app/assets/stylesheets/application.css 中的 application.css
/*
* 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 vendor/assets/stylesheets of plugins, if any, 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 top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require 'masonry/transitions'
*= require_tree
*= require font-awesome
*= require bootstrap
*= require magnific-popup
*/
我不确定出了什么问题,我尝试预编译资产,但仍然无法正常工作,我会遗漏什么?
我的布局中有指向我的样式表的链接,app/views/layouts/application.html.erb
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
【问题讨论】:
-
你的 application.css 是什么样的,这个 bootstrap.css.scss 位于哪里?
-
@Iceman,我刚刚用你的要求编辑了我的问题!
-
我认为您的
*= require_tree上缺少一个句号 - 我很确定它应该是*= require_tree . -
是的库尔特,我错过了 *= require_tree 之后的时间段。但它并没有成功,它仍然无法正常工作:)
标签: css ruby-on-rails asset-pipeline assets