为什么这个Compass @import在Rails中不起作用?

时间:2013-01-22 14:02:54

标签: ruby-on-rails ruby-on-rails-3 compass-sass

test_app /应用/资产/样式表/ application.css.scss

@import 'compass';
@import 'variables';
@media only screen and (min-width: $breakpoint-medium-additional-width) {
  @import 'partials/medium-additional';
}

test_app /应用/资产/样式表/ _variables.scss

$breakpoint-medium-additional-width: 28em;

当我尝试访问某个页面(正在开发中)时,会发生此Rails错误:

Sass::SyntaxError at /
Invalid CSS after "...nd (min-width: ": expected expression (e.g. 1px, bold), was "$breakpoint-med..." (in /Users/ben/rails_projects/test_app/app/assets/stylesheets/application.css.scss)

为什么$breakpoint-medium-additional-width设置不正确?

我正在使用

  • Rails 3.2.11
  • ruby​​ 1.9.3
  • 指南针0.12.2
  • compass-rails 1.0.3

1 个答案:

答案 0 :(得分:1)

我认为你的代码中有拼写错误。我创建了一个新的rails项目,它对我来说很好。

app / assets / stylesheets / _variables.scss

$breakpoint-medium-additonal-width: 28em;

应用程序/资产/样式表/ application.scss

@import 'compass';
@import 'variables';
@media only screen and (min-width: $breakpoint-medium-additonal-width) {
  font-size: 120%;
}

输出application.css

@media only screen and (min-width: 28em) {
  font-size: 120%;
}