rails中的样式表清单并不响应某些`require _____`行

时间:2014-06-23 00:43:02

标签: ruby-on-rails asset-pipeline

为什么样式表清单(application.css.scss)中的常用//*= require name_of_thing无效?我必须单独包含@import name_of_thing


例如,select2 gem指令(https://github.com/argerim/select2-rails)表示要输入

*= require select2
*= require select2-bootstrap
application.css.scss文件中的

但它没有效果。相反,我必须输入

@import "select2";
@import "select2-bootstrap";

我试过包括两个,包括一个,包括另一个,删除两者,并通过测试得出结论,注释掉的请求没有效果,只有@import指令有效。

为什么这会发生在我的铁轨上?我的配置错误了什么?


另外,*= require tree .应该处理的内容也不会包含在我的浏览器中

例如,我有一个角色脚手架。在字符的show view上,charater.css.scss中的css没有加载到浏览器中。相反,我必须手动@import "characters"。为什么是这样?

但是,*= require_self有效。


我的整个application.css.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 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.
 *
 */
@import "resets";
@import "bootstrap";
/* blanket styles */
@import "custom/cp_variables";
@import "custom/cp_custom";
@import "custom/cp_responsive";
/* controller-specific styles */
@import "socionics";
@import "characters";
@import "comments";
@import "votes";
/* plugin styles */
@import "spritz";
@import "select2";
@import "select2-bootstrap";
/*
 *= require select2
 *= require select2-bootstrap
 *= require_self
 *= require tree .
 */

1 个答案:

答案 0 :(得分:0)

远程调试很困难。我的建议是完全摆脱@import

尝试:

/*
 *= require select2
 *= require select2-bootstrap
 *= require_self
 *= require_tree .
 */

请注意订单,require_tree和评论方式。