Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-3.2sassscaffolding

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?


Solution

  • Look at this StackOverflow answer

    rails g scaffold MyModel --no-stylesheets