deface
deface copied to clipboard
Disabling deface when initialize_on_precompile is disabled
Setting config.deface.enabled = false
in the production environment config when you have initialize_on_precompile
disabled in config/application.rb will cause the following error:
undefined method `deface' for #<Rails::Application::Configuration:0x007fce85dc5fe0>
My workaround is to actually add a guard like this - if config.respond_to?(:deface)
I'm guessing there's another place the config setting can be defined so that it's available without initializing?
Here's where we set the config:
https://github.com/spree/deface/blob/master/lib/deface/railtie.rb#L22
I'm open to suggestions for a different hook to add it :before ?
I've got no clue, honestly.
Looking at how other projects handle it, it seems like we could do one of the following:
- Put this into an initializer instead. We could change the documentation to suggest this.
- Use a class-level setting, like:
Deface.configuration do |config|
config.enabled = false
end
That's how it looks like other people do it.
By the way, would it be possible to just make this happen as part of Asset Precompilation altogether somehow?