views:

147

answers:

2

Hi,

Is there a way to get your SCSS files to automatically generate new CSS each time a file is changed as part of Rails, without having to use sass --watch? Or is this just meant to happen anyway?

By this I mean having rails do the watching for you, or maybe if it can recompile all SCSS every page load in development that is fine too.

Also, perhaps HAML is not loading properly, as if I include the line:

Sass::Plugin.options[:always_update] = true

after my initializer block in environment.rb, then I get the following exception on startup:

/persistent/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant Sass (NameError)

I am working with Rails v 2.3.5, and HAML v 3.0.18, and have "config.gem 'haml', :version => '3.0.18'" in my initializer block.

Thanks for your help.

A: 

The config.gem "haml" line should load both Haml and Sass. Do you have any old versions of Haml hanging around? Does it work if you load it in a brand new application?

nex3
I don't have any old versions of HAML - yet to try a new application, will give that a go. Cheers.
Jaidev Soin
A: 

Okay, I seem to have found the solution.

Just including the line

config.gem "haml"

Isn't necessarily all you need, as this gem also needs to be loaded as a plugin to get the rails functionality. So, if you are using config.plugins = [] to limit which plugins are loaded, you need to specifically list 'haml' in there. If you aren't using config.plugins then it's all good, the plugin functionality of the gem will be loaded automatically.

Jaidev Soin