ben
ben

Reputation: 29767

Why is this Compass @import not working in Rails?

test_app/app/assets/stylesheets/application.css.scss

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

test_app/app/assets/stylesheets/_variables.scss

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

When I try to visit a page (in development), this Rails error occurs:

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)

Why is $breakpoint-medium-additional-width not being set correctly?

I'm using

Upvotes: 0

Views: 485

Answers (1)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

I think you have a typo in your code. I created a new rails project, and it works fine for me.

app/assets/stylesheets/_variables.scss

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

app/assets/stylesheets/application.scss

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

The output application.css

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

Upvotes: 1

Related Questions