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
?
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
Look at this StackOverflow answer
rails g scaffold MyModel --no-stylesheets
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With