Created
September 1, 2014 14:11
-
-
Save ryotarai/4adb47be64d1003e306f to your computer and use it in GitHub Desktop.
Use better_errors in production env
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
# config/application.rb | |
module BetterErrors | |
class Railtie < Rails::Railtie | |
def use_better_errors? | |
return true if ENV['BETTER_ERRORS'] | |
!Rails.env.production? and app.config.consider_all_requests_local | |
end | |
end | |
end | |
# config/environments/production.rb | |
Rails.application.configure do | |
config.consider_all_requests_local = !!ENV['BETTER_ERRORS'] | |
config.action_controller.perform_caching = !!!ENV['BETTER_ERRORS'] | |
end | |
# config/initializers/better_errors.rb | |
BetterErrors::Middleware.allow_ip! '192.168.0.0/24' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment