rails/rails — Issue #4761: assets:precompile does not work locally, if production config contains "production only" settings
Author: harrikauhanen
Created: 2012-01-30 17:04:46+00:00
State: open

Background: You need to compile assets on your development host before the deployment to the production site. On the production site you also need to store log files to a custom directory. (You might be using some sort of read-only filesystem, war-deployment etc.)

If you put something like this into *config/environments/production.rb*...

```config.logger = Logger.new("/this/directory/exists/on/production/only")```

...the ```rake assets:precompile``` will fail complaining about non-existing directory.

You may tackle this case by refining the config:

```
# This or some other way to detect you are not on "real" production yet
unless Rails.groups.include?('assets')
config.logger = Logger.new("/this/path/exists/on/production/only")
end
```

You could, however, have many other cases where your production config (or other initializers) work correctly only if run on real production environment.