Skip to content

Instantly share code, notes, and snippets.

@ryotarai
Created September 1, 2014 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryotarai/4adb47be64d1003e306f to your computer and use it in GitHub Desktop.
Save ryotarai/4adb47be64d1003e306f to your computer and use it in GitHub Desktop.
Use better_errors in production env
# 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