0

I'm using rails with compass.

When using rails without compass, rails has a css per each controller, which contains things that are only relevant to the views in that controller.

I couldn't get the same behavior with compass, which resulted in having a big monolithic file instead of separate files per controller.

What is the recommended approach to solving that problem?

davidrac
  • 10,723
  • 3
  • 39
  • 71
  • 1
    By compass I guess you meant SASS? Anyway, what's the reason? Usually, sending CSS/JS files only once on the initial load is useful since browsers then don't have anything extra to download on subsequent pages. BUt if you need it, here's an explanation for JS ... shouldn't be hard to adapt to CSS : http://stackoverflow.com/questions/6571753/rails-3-1-asset-pipeline-how-to-load-controller-specific-scripts – Anthony Alberto Mar 05 '13 at 14:32
  • By compass I mean compass (http://compass-style.org/). Thanks for the reference. – davidrac Mar 05 '13 at 19:36

1 Answers1

0

Rails (since 3.1) does create a css file per controller but it's only for practical code separation, all code assets get compiled into one master file per format (.css, .js..), and this is the best practice 90% of the time.

If you want to use this approach with SCSS or SASS code, just change the file extension to .css.scss or .css.sass (ie: mycontroller.css.scss)

If you want to separate the compiled files per controller (you probably don't need it, so i'd advise that you understand the asset pipeline before doing it), you'll have to implement the custom behavior yourself. take a look here http://guides.rubyonrails.org/asset_pipeline.html

3amsleep
  • 464
  • 3
  • 4