Search code examples
ruby-on-railsruby-on-rails-3stylesheetcoffeescriptassets

Why isn't my stylesheet being included in my Rails 3 app?


I had created a scaffold users with all of the attendant views, controllers, stylesheets, etc. I then renamed the contoller, model, DB table, and files to supporters.

Everything is working fine, and I'm happy with how it's working except for one thing: app/assets/stylesheets/supporters.css.scss is not being loaded with the supporter views.

All other controllers' stylesheets are loading properly since <%= stylesheet_link_tag "application" %> is in my application.html.erb file from the rails default.

I renamed the users.js.coffee file to supporters.js.coffee and that is being included. For what it's worth, I deleted the users.css.scss file and then created a new supporters.css.scss file.

Is there anything else I need to do to get the file to load with my supporters views?


Solution

  • The answer was to remove the =require_tree line from the header, and add the line @import "supporters.css.scss"; immediately after the header, along with similar import statements for other controllers' stylesheets.

    I was expecting Rails to do some magic loading up of the right stylesheet depending on what controller was being used. Sass does no such thing.

    Answer found here.