title: Proper SCSS Asset Structure in Rails
body: <p>So, I have an <code>app/assets/stylesheets/</code> directory structure that looks something like this:</p>
  
  <pre><code>   |-dialogs
     |-mixins
     |---buttons
     |---gradients
     |---vendor_support
     |---widgets
     |-pages
     |-structure
     |-ui_elements
  </code></pre>
  
  <p>In each directory, there are multiple sass partials (usually *.css.scss, but one or two *.css.scss.erb).</p>
  
  <p>I might be assuming a lot, but rails SHOULD automatically compile all the files in those directories because of <code>*= require_tree .</code> in application.css, right?</p>
  
  <p>I recently have tried restructuring these files by removing all color variables and placing them in a file in the root <code>app/assets/stylesheets</code> folder (_colors.css.scss). I then created a file in the root <code>app/assets/stylesheets</code> folder called master.css.scss which looks like this:</p>
  
  <pre><code>// Color Palette 
  @import "colors";
  
  // Mixins
  @import "mixins/buttons/standard_button";
  @import "mixins/gradients/table_header_fade";
  @import "mixins/vendor_support/rounded_corners";
  @import "mixins/vendor_support/rounded_corners_top";
  @import "mixins/vendor_support/box_shadow";
  @import "mixins/vendor_support/opacity";
  </code></pre>
  
  <p>I don't really understand how rails handles the order of asset compilation, but it's obviously not in my favor. It appears none of the files realize they have any variables or mixins being imported, and so it throws errors and I can't compile. </p>
  
  <pre><code>Undefined variable: "$dialog_divider_color".
    (in /home/blah/app/assets/stylesheets/dialogs/dialog.css.scss.erb)
  
  Undefined mixin 'rounded_corners'.
    (in /home/blah/app/assets/stylesheets/widgets.css.scss)
  </code></pre>
  
  <p>The variable <code>$dialog_divider_color</code> is clearly defined in _colors.css.scss, and <code>_master.css.scss</code> is importing colors and all my mixins. But apparently rails didn't get that memo.</p>
  
  <p>Is there some way I can fix these errors, or will I need to resort to putting all my variable definitions back into each individual file, as well as all the mixin imports?</p>
  
  <p>Unfortunately, <a href="https://stackoverflow.com/questions/8887824/persisting-scss-variables-in-rails-asset-pipeline">this guy</a> doesn't seem to think it's possible, but I'm hoping he's wrong. Any thoughts are greatly appreciated.</p>