rails/rails — Issue #3513: config.sass options can't be set in production 
Author: dmitriy-kiriyenko
Created: 2011-11-04 08:12:14+00:00
State: open

Hi all.

Default generated Rails application includes assets related gems in `group :assets` and requires them the following way:

``` ruby
Bundler.require(*Rails.groups(:assets => %w(development test)))
```

which means only require asset gems in non-development and non-test environment. So these gems should only be loaded during `assets:precompile` and not during rails server start in production environment.

However, the official [sass-rails](https://github.com/rails/sass-rails) gem suggests us configure sass options via `config.sass`. So I'm supposed to add to my `config/environments/production.rb` something like:

``` ruby
config.sass.line_comments = false
```

if, say, I want do disable line comments, which are enabled by default. I'm aware of `assets.compress` option, which also allows me to remove comments, but what if I do not want to compress? Or let's say I want to configure some other sass option.

The problem is that while it works during assets:precompile it fails during server start in production mode with message `undefined method 'sass' for Rails::Application::Configuration`.

Not sure how this problem should be properly eliminated. I used a temporary workaround:

``` ruby
config.sass.line_comments = false if config.respond_to? :sass
```

but I think something should be done about this. What do you think?

One solution could be defining method_missing on `Rails::Application::Configuration` in a way that if it's not setter, not bang and not predicate it would call appropriate setter with `ActiveSupport::OrderedOptions.new` and return that object. This will eliminate the current problem and will also greatly simplify adding own nested configuration variables to rails configuration. If it's ok, I could provide a patch with this.

Or maybe it should be fixed withing sass-rails? /cc @chriseppstein