Omar Al-Shammary
Omar Al-Shammary

Reputation: 314

rails: any change to custom.css.scss make the app crash

I'm learning rails. I have this problem and I hope you can help me.

This is my 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;
    }
  }
}

and if I do any change to this file, just like pressing enter (adding an empty line) would make my app crash.

This is the error I get

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

any help is appreciated.

Upvotes: 3

Views: 2185

Answers (2)

Chitresh goyal
Chitresh goyal

Reputation: 333

I got Same issue when I used INSPINIA theme and one custom bootstrap theme together.

According to this error the css file in which $grayLight variable is defined should load before another file.

To make a sequence of assets pre-compilation, use this way in your config/application.rb file

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

Upvotes: 0

user740584
user740584

Reputation:

As the error is telling you, $grayLight is not defined as a variable. When you change a scss file it will automatically compile the css and since this variable does not exist, you get the error.

Are you using bootstrap-sass? If so, the "light gray" variable is actually $gray-light. ($grayDarker should also be $gray-darker).

Upvotes: 6

Related Questions