Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails scaffolds scss reset each time a scaffold is generated

Each time I do a rails generate scaffold Name, the app/assets/stylesheets/scaffolds.css.scss file is overwritten (well I get prompted to overwrite it). I don't want this, so of course I could just type n when prompted to overwrite, but I want to know the proper way to handle styling of scaffolds.

I could just write the css in a css file loaded later to override the necessary css in the scaffolds.css.scss file. But not only is that ugly (have unnecessary/unused css being generated and loaded every request), but I don't know how to not change the foreground and background colors upon hovering over links (from scaffolds.css.scss):

a {
  &:hover {
    color: #fff;
    background-color: #000;
  }
}

What's the proper way to remove something like the above from scaffolds.css.scss?

like image 616
at. Avatar asked Oct 05 '12 17:10

at.


3 Answers

Want to disable disable stylesheet forever, or usually forgot --no-stylesheets switch(I DO!)

Disable stylesheet in your generator!!

config/application.rb

config.generators do |g|
 g.stylesheets false
end
like image 192
Naveed Avatar answered Oct 24 '22 11:10

Naveed


Look at this StackOverflow answer

rails g scaffold MyModel --no-stylesheets

like image 26
claptimes Avatar answered Oct 24 '22 09:10

claptimes


Remember that you can always redefine these things in your own stylesheets, and include them later than the scaffolding stylesheets by modifying assets/stylesheets/application.css

 *= require_self
 *= require scaffolds
 *= require YOUR_FILE

(If you don't fiddle with application.css, by default the stylesheets get included in alphabetical order, which may or may not be what you want.)

like image 35
Scott C Wilson Avatar answered Oct 24 '22 10:10

Scott C Wilson