Created
July 20, 2020 08:36
-
-
Save sauloperez/e37856fe77af67207fd9ca32a2e9573f to your computer and use it in GitHub Desktop.
Complete production-like development-mode profiling environment
This file contains 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
Rails.application.configure do | |
# Settings specified here will take precedence over those in config/application.rb. | |
# In the development environment your application's code is reloaded on | |
# every request. This slows down response time but is perfect for development | |
# since you don't have to restart the web server when you make code changes. | |
config.cache_classes = !!ENV["PROFILE"] | |
# Do not eager load code on boot. | |
config.eager_load = !!ENV["PROFILE"] | |
# Show full error reports. | |
config.consider_all_requests_local = true | |
# Enable/disable caching. By default caching is disabled. | |
# Run rails dev:cache to toggle caching. | |
if Rails.root.join('tmp', 'caching-dev.txt').exist? | |
config.action_controller.perform_caching = true | |
config.cache_store = :memory_store | |
config.public_file_server.headers = { | |
'Cache-Control' => "public, max-age=#{2.days.to_i}" | |
} | |
else | |
config.action_controller.perform_caching = false | |
config.cache_store = :null_store | |
end | |
# Store uploaded files on the local file system (see config/storage.yml for options) | |
config.active_storage.service = :local | |
# Don't care if the mailer can't send. | |
config.action_mailer.raise_delivery_errors = false | |
config.action_mailer.delivery_method = :letter_opener_web | |
config.action_mailer.default_url_options = { port: 3000 } | |
config.action_mailer.perform_caching = false | |
# Print deprecation notices to the Rails logger. | |
config.active_support.deprecation = :log | |
# Raise an error on page load if there are pending migrations. | |
config.active_record.migration_error = ENV["PROFILE"] ? false : :page_load | |
# Highlight code that triggered database queries in logs. | |
config.active_record.verbose_query_logs = !ENV["PROFILE"] | |
# Debug mode disables concatenation and preprocessing of assets. | |
# This option may cause significant delays in view rendering with a large | |
# number of complex assets. | |
config.assets.debug = !ENV["PROFILE"] | |
# Suppress logger output for asset requests. | |
config.assets.quiet = true | |
if ENV["PROFILE"] | |
config.public_file_server.enabled = true | |
config.public_file_server.headers = { | |
'Cache-Control' => 'public, s-maxage=31536000, maxage=31536000', | |
'Expires' => "#{1.year.from_now.to_formatted_s(:rfc822)}" | |
} | |
config.assets.compile = false | |
# Prod-like logging | |
logger = ActiveSupport::Logger.new(STDOUT) | |
logger.formatter = config.log_formatter | |
config.logger = ActiveSupport::TaggedLogging.new(logger) | |
config.action_view.cache_template_loading = true | |
end | |
# Raises error for missing translations | |
# config.action_view.raise_on_missing_translations = true | |
# Use an evented file watcher to asynchronously detect changes in source code, | |
# routes, locales, etc. This feature depends on the listen gem. | |
config.file_watcher = ActiveSupport::EventedFileUpdateChecker | |
# No precompilation on demand on first request | |
config.assets.check_precompiled_asset = false | |
require 'bullet' unless ENV["PROFILE"] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taken from codetriage/CodeTriage@a3c9576 and also inspired by https://github.com/rubygems/rubygems.org/blob/b026df86ae9df0e4d4c7dae2f220fe2219d52350/config/environments/development.rb.