rails:对custom.css.scss的任何更改都会导致应用程序崩溃

我正在学习铁轨。 我有这个问题,希望你能帮助我。

这是我的custome.css.scss:

@import "bootstrap"; /* mixins, variables, etc. */ $grayMediumLight: #eaeaea; /* universal */ html { overflow-y: scroll; } body { padding-top: 60px; } section { overflow: auto; } textarea { resize: vertical; } .center { text-align: center; h1 { margin-bottom: 10px; } } /* typography */ h1, h2, h3, h4, h5, h6 { line-height: 1; } h1 { font-size: 3em; letter-spacing: -2px; margin-bottom: 30px; text-align: center; } h2 { font-size: 1.2em; letter-spacing: -1px; margin-bottom: 30px; text-align: center; font-weight: normal; color: $grayLight; } p { font-size: 1.1em; line-height: 1.7em; } /* header */ #logo { float: left; margin-right: 10px; font-size: 1.7em; color: white; text-transform: uppercase; letter-spacing: -1px; padding-top: 9px; font-weight: bold; line-height: 1; &:hover { color: white; text-decoration: none; } } /* footer */ footer { margin-top: 45px; padding-top: 5px; border-top: 1px solid $grayMediumLight; color: $grayLight; a { color: $gray; &:hover { color: $grayDarker; } } small { float: left; } ul { float: right; list-style: none; li { float: left; margin-left: 10px; } } } 

如果我对此文件进行任何更改,就像按Enter键(添加空行)会使我的应用程序崩溃。

这是我得到的错误

 Undefined variable: "$grayLight". (in C:/Sites/rails_projects/sample_app/app/assets/stylesheets/custom.css.scss:52) 

任何帮助表示赞赏。

正如错误告诉您的那样, $grayLight未定义为变量。 当您更改scss文件时,它将自动编译css,因为此变量不存在,您将收到错误。

你在使用bootstrap-sass吗? 如果是这样,“浅灰色”变量实际上是$gray-light 。 ( $grayDarker也应该是$gray-darker )。

当我使用INSPINIA主题和一个自定义引导主题时,我遇到了同样的问题。

根据此错误,定义$ grayLight变量的css文件应该在另一个文件之前加载。

要创建一系列资产预编译,请在config / application.rb文件中使用此方法

 config.assets.precompile += [ 'application.js', 'variable.js', 'custom.js'] config.assets.precompile += [ 'application.css', 'variable.css', 'custom.css']