Ruby on rails Sass::SyntaxError未定义变量

Ruby on rails Sass::SyntaxError未定义变量,ruby-on-rails,ruby-on-rails-3.2,sass,asset-pipeline,Ruby On Rails,Ruby On Rails 3.2,Sass,Asset Pipeline,我是资产管道的新手,所以如果我做错了,请告诉我 将Rails 3.2与SASS一起使用。我有一个配置部分,它定义了我希望在整个scss文件中使用的一组SASS变量。根据,我首先导入配置,然后导入奖金。但是,我一直在bonus.css.scss中看到一个Sass::SyntaxError说未定义的变量:“$darkRed”。我做错了什么 application.css.scss /* * This is a manifest file that'll be compiled into appli

我是资产管道的新手,所以如果我做错了,请告诉我

将Rails 3.2与SASS一起使用。我有一个配置部分,它定义了我希望在整个scss文件中使用的一组SASS变量。根据,我首先导入
配置
,然后导入
奖金
。但是,我一直在bonus.css.scss中看到一个
Sass::SyntaxError
未定义的变量:“$darkRed”
。我做错了什么

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 "configuration";
@import "bootstrap";
@import "bonus";
//colors
$darkRed: #B94A48;
$controlColor: #777;
_configuration.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 "configuration";
@import "bootstrap";
@import "bonus";
//colors
$darkRed: #B94A48;
$controlColor: #777;
bonus.css.scss

div.give-inline-help .help-inline
  {
  color: $darkRed;
  font-size: 15px;
  font-family: MuseoSans-300;
  padding-left: 0px;
}

您在
application.css.scss
中导入了名称错误的scss文件:

替换:
@import“配置”

使用:
@import“\u配置”


或者将
\u configuration.css.scss
文件重命名为
configuration.css.scss
您在
application.css.scss
中导入的scss文件名称错误:

替换:
@import“配置”

使用:
@import“\u配置”


或者将您的
\u configuration.css.scss
文件重命名为
configuration.css.scss
,因此我偶然遇到了这个问题,想给出一个更准确的答案:

非下划线命名文件下游链中的任何
@import
ed文件将与
Sass::SyntaxError未定义变量
中断

使用Sass,如果要覆盖变量,必须确保使用不间断的下划线文件链


就这么简单,虽然有时很容易通过

所以我偶然发现了这个问题,想给出一个更准确的答案:

非下划线命名文件下游链中的任何
@import
ed文件将与
Sass::SyntaxError未定义变量
中断

使用Sass,如果要覆盖变量,必须确保使用不间断的下划线文件链


就这么简单,虽然有时很容易通过

这是Rails特有的吗?因为“configuration”和“_configuration”在Rails之外的Sass中是可互换的。请看一看:“如果您以下划线开头命名导入的文件,那么Sass不会尝试编译这些文件。”您误解了这意味着什么。下划线只是告诉Sass在编译时不要创建CSS文件。这并不意味着“嘿,完全忽略这个文件的所有内容。”啊哈,谢谢你的澄清:)我尝试了这个,得到了这个错误
文件导入未找到或无法读取
这是Rails特有的吗?因为“configuration”和“_configuration”在Rails之外的Sass中是可互换的。请看一看:“如果您以下划线开头命名导入的文件,那么Sass不会尝试编译这些文件。”您误解了这意味着什么。下划线只是告诉Sass在编译时不要创建CSS文件。这并不意味着“嘿,完全忽略这个文件的所有内容。”啊哈,谢谢你的澄清:)我尝试了这个方法,得到了这个错误
文件导入未找到或无法读取
是否没有干净利落的方法将这些定义包含在下游?@jwg2s-只需将顶层保留为非下划线,所有以下划线为前缀的内容都解决了这个问题。现在有点道理了,任何未加下划线的文件都有自己的离散作用域,而加下划线的文件属于其他文件的作用域。是否没有干净利落的方法将这些定义包含在下游?@jwg2s-只需将顶层保留为非下划线,其他所有文件都以下划线作为前缀即可解决问题。现在有点道理了,任何未加下划线的文件都有自己的离散范围,而加下划线的文件属于另一个文件的范围。这是一个3年以上的问题…你现在将其标记为重复?这是一个3年以上的问题…你现在将其标记为重复?