deface icon indicating copy to clipboard operation
deface copied to clipboard

Disabling deface when initialize_on_precompile is disabled

Open jroes opened this issue 12 years ago • 2 comments

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?

jroes avatar Feb 21 '13 15:02 jroes

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 ?

BDQ avatar Feb 21 '13 16:02 BDQ

I've got no clue, honestly.

Looking at how other projects handle it, it seems like we could do one of the following:

  1. Put this into an initializer instead. We could change the documentation to suggest this.
  2. 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?

jroes avatar Feb 21 '13 16:02 jroes