Explaining the main.css.scss file
The Ruby on Rails setup compiles all the .scss
files into CSS by default. In this recipe, you will learn how to organize your Sass files for code reuse and meeting the Don't Repeat Yourself (DRY) methodology.
Getting ready
Read the Hello world with Ruby on Rails recipe of this chapter to find out how to setup a Ruby on Rails web application.
How to do it...
The following step demonstrate you how to organize the Sass files of your RoR app to develop your CSS code DRY:
- Repeat all the steps of the Hello world with Ruby on Rails recipe or copy the
recipe1
folder to therecipe2
folder. - Then rename the
app/assets/stylesheets/application.css
file toapp/assets/stylesheets/application.scss
. - Remove the content of the
app/assets/stylesheets/application.scss
file and write the following line of SCSS code into it:@import 'headers';
- Create a new partial file called
app/assets/stylesheets/_headers.scss
and write down the SCSS code shown here into it:h1 { color...