10

Can you configure rails to only run an initializer under certain environments? In my case I had to hack paperclip to work with Imagemagick on my dev box, so I have monkeypatched code I want only to apply to the development environ, not the production environment. That monkeypatch is saved as a file in config\initializers.

The guides.rubyonrails.org site does not indicate that one can do this. If I can't I suppose I just won't check this patch into my repo, but that would not be ideal.

1 Answer 1

19

You could put this in an after_initialize block in config/environments/development.rb, or just surround it with if Rails.env.development? in the initializer you already have.

I think either of these would work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.