3

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.

2 Answers 2

6

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).

Sign up to request clarification or add additional context in comments.

3 Comments

I'm using bootstrap-saas, the problem is only occur when I modify the file, any type of mdification, I only get rid of this error by pressing CRTL+Z (Undo), even when I tried to change lightgray to light-gray, it would give me an error that ligh-gray is not defined
It's not $light-gray, it's $gray-light (and there's more than one occurrence in your css file). You can see all the available variables at github.com/thomas-mcdonald/bootstrap-sass/blob/master/vendor/…
Thank you, my mistake was, I had originally grayLight, I changed it to gray-Light, and it seems that CSS is case sensitive
0

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']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.