Skip to content

Commit 156e4b1

Browse files
committed
Updated app with rails app:update
This brings various rails files to current standards.
1 parent 7f23ec9 commit 156e4b1

File tree

10 files changed

+159
-117
lines changed

10 files changed

+159
-117
lines changed

bin/setup

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
#!/usr/bin/env ruby
2-
require 'pathname'
32
require 'fileutils'
4-
include FileUtils
53

64
# path to your application root.
7-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
5+
APP_ROOT = File.expand_path('..', __dir__)
86

97
def system!(*args)
108
system(*args) || abort("\n== Command #{args} failed ==")
119
end
1210

13-
chdir APP_ROOT do
14-
# This script is a starting point to setup your application.
11+
FileUtils.chdir APP_ROOT do
12+
# This script is a way to setup or update your development environment automatically.
13+
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
1514
# Add necessary setup steps to this file.
1615

1716
puts '== Installing dependencies =='
1817
system! 'gem install bundler --conservative'
1918
system('bundle check') || system!('bundle install')
2019

21-
2220
# puts "\n== Copying sample files =="
2321
# unless File.exist?('config/database.yml')
24-
# cp 'config/database.yml.sample', 'config/database.yml'
22+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
2523
# end
2624

2725
puts "\n== Preparing database =="
28-
system! 'bin/rails db:setup'
26+
system! 'bin/rails db:prepare'
2927

3028
puts "\n== Removing old logs and tempfiles =="
3129
system! 'bin/rails log:clear tmp:clear'

config/application.rb

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
require 'rails'
44

5+
# Pick the frameworks you want:
56
require 'active_model/railtie'
7+
# require "active_job/railtie"
68
require 'active_record/railtie'
7-
9+
# require "active_storage/engine"
810
require 'action_controller/railtie'
11+
# require "action_mailer/railtie"
12+
# require "action_mailbox/engine"
13+
# require "action_text/engine"
914
require 'action_view/railtie'
15+
# require "action_cable/engine"
16+
# require "sprockets/railtie"
17+
# require "rails/test_unit/railtie"
1018

1119
# Require the gems listed in Gemfile, including any gems
1220
# you've limited to :test, :development, or :production.
@@ -52,8 +60,9 @@ class Application < Rails::Application
5260
config.autoload_paths << Rails.root.join('app', 'validators')
5361

5462
# Settings in config/environments/* take precedence over those specified here.
55-
# Application configuration should go into files in config/initializers
56-
# -- all .rb files in that directory are automatically loaded.
63+
# Application configuration can go into files in config/initializers
64+
# -- all .rb files in that directory are automatically loaded after loading
65+
# the framework and any gems in your application.
5766

5867
# Only loads a smaller set of middleware suitable for API only apps.
5968
# Middleware like session, flash, cookies can be added back manually.

config/environments/development.rb

+16-20
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,36 @@
99
# Do not eager load code on boot.
1010
config.eager_load = false
1111

12-
# Print deprecation notices to the Rails logger.
13-
config.active_support.deprecation = :log
14-
15-
# Raise an error on page load if there are pending migrations.
16-
config.active_record.migration_error = :page_load
17-
18-
# Raises error for missing translations
19-
# config.action_view.raise_on_missing_translations = true
20-
21-
# Use an evented file watcher to asynchronously detect changes in source code,
22-
# routes, locales, etc. This feature depends on the listen gem.
23-
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
24-
2512
# Show full error reports.
2613
config.consider_all_requests_local = true
2714

2815
# Enable/disable caching. By default caching is disabled.
16+
# Run rails dev:cache to toggle caching.
2917
if Rails.root.join('tmp', 'caching-dev.txt').exist?
30-
config.action_controller.perform_caching = true
31-
3218
config.cache_store = :memory_store
3319
config.public_file_server.headers = {
34-
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
20+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
3521
}
3622
else
3723
config.action_controller.perform_caching = false
3824

3925
config.cache_store = :null_store
4026
end
4127

42-
# Don't care if the mailer can't send.
43-
# config.action_mailer.raise_delivery_errors = false
28+
# Print deprecation notices to the Rails logger.
29+
config.active_support.deprecation = :log
30+
31+
# Raise an error on page load if there are pending migrations.
32+
config.active_record.migration_error = :page_load
33+
34+
# Highlight code that triggered database queries in logs.
35+
config.active_record.verbose_query_logs = true
36+
4437

45-
# config.action_mailer.perform_caching = false
38+
# Raises error for missing translations.
39+
# config.action_view.raise_on_missing_translations = true
4640

47-
config.public_file_server.enabled = true
41+
# Use an evented file watcher to asynchronously detect changes in source code,
42+
# routes, locales, etc. This feature depends on the listen gem.
43+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
4844
end

config/environments/production.rb

+46-31
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,28 @@
1010
# Rake tasks automatically ignore this option for performance.
1111
config.eager_load = true
1212

13-
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
14-
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
15-
# `config/secrets.yml.key`.
13+
# Full error reports are disabled and caching is turned on.
14+
config.consider_all_requests_local = false
15+
config.action_controller.perform_caching = true
16+
17+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
18+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
19+
# config.require_master_key = true
1620
config.read_encrypted_secrets = true
1721

22+
# Disable serving static files from the `/public` folder by default since
23+
# Apache or NGINX already handles this.
24+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
1825

26+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
27+
# config.action_controller.asset_host = 'http://assets.example.com'
28+
29+
# Specifies the header that your server uses for sending files.
30+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
31+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
32+
33+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
34+
# config.force_ssl = true
1935

2036
# Use the lowest log level to ensure availability of diagnostic information
2137
# when problems arise.
@@ -33,9 +49,9 @@
3349
# Use a different cache store in production.
3450
# config.cache_store = :mem_cache_store
3551

36-
# Use a real queuing backend for Active Job (and separate queues per environment)
52+
# Use a real queuing backend for Active Job (and separate queues per environment).
3753
# config.active_job.queue_adapter = :resque
38-
# config.active_job.queue_name_prefix = "rmt_#{Rails.env}"
54+
# config.active_job.queue_name_prefix = "rmt_production"
3955

4056
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
4157
# the I18n.default_locale when a translation cannot be found).
@@ -44,37 +60,36 @@
4460
# Send deprecation notices to registered listeners.
4561
config.active_support.deprecation = :notify
4662

63+
# Use default logging formatter so that PID and timestamp are not suppressed.
64+
# config.log_formatter = ::Logger::Formatter.new
65+
66+
# Use a different logger for distributed setups.
67+
# require 'syslog/logger'
4768
config.logger = RMT::Logger.new(STDOUT)
4869

4970
# Do not dump schema after migrations.
5071
config.active_record.dump_schema_after_migration = false
5172

52-
# Full error reports are disabled and caching is turned on.
53-
config.consider_all_requests_local = false
54-
config.action_controller.perform_caching = true
55-
56-
# Disable serving static files from the `/public` folder by default since
57-
# Apache or NGINX already handles this.
5873
config.public_file_server.enabled = true
5974

60-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
61-
# config.action_controller.asset_host = 'http://assets.example.com'
62-
63-
# Specifies the header that your server uses for sending files.
64-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
65-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
66-
67-
# Mount Action Cable outside main process or domain
68-
# config.action_cable.mount_path = nil
69-
# config.action_cable.url = 'wss://example.com/cable'
70-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
71-
72-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
73-
# config.force_ssl = true
74-
75-
# config.action_mailer.perform_caching = false
76-
77-
# Ignore bad email addresses and do not raise email delivery errors.
78-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
79-
# config.action_mailer.raise_delivery_errors = false
75+
# Inserts middleware to perform automatic connection switching.
76+
# The `database_selector` hash is used to pass options to the DatabaseSelector
77+
# middleware. The `delay` is used to determine how long to wait after a write
78+
# to send a subsequent read to the primary.
79+
#
80+
# The `database_resolver` class is used by the middleware to determine which
81+
# database is appropriate to use based on the time delay.
82+
#
83+
# The `database_resolver_context` class is used by the middleware to set
84+
# timestamps for the last write to the primary. The resolver uses the context
85+
# class timestamps to determine how long to wait before reading from the
86+
# replica.
87+
#
88+
# By default Rails will store a last write timestamp in the session. The
89+
# DatabaseSelector middleware is designed as such you can define your own
90+
# strategy for connection switching and pass that into the middleware through
91+
# these configuration options.
92+
# config.active_record.database_selector = { delay: 2.seconds }
93+
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
94+
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
8095
end

config/environments/test.rb

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1+
# The test environment is used exclusively to run your application's
2+
# test suite. You never need to work with it otherwise. Remember that
3+
# your test database is "scratch space" for the test suite and is wiped
4+
# and recreated between test runs. Don't rely on the data there!
5+
16
Rails.application.configure do
27
# Settings specified here will take precedence over those in config/application.rb.
38

4-
# The test environment is used exclusively to run your application's
5-
# test suite. You never need to work with it otherwise. Remember that
6-
# your test database is "scratch space" for the test suite and is wiped
7-
# and recreated between test runs. Don't rely on the data there!
8-
config.cache_classes = true
9+
config.cache_classes = false
10+
config.action_view.cache_template_loading = true
911

1012
# Do not eager load code on boot. This avoids loading your whole application
1113
# just for the purpose of running a single test. If you are using a tool that
1214
# preloads Rails for running tests, you may have to set it to true.
1315
config.eager_load = false
1416

15-
# Print deprecation notices to the stderr.
16-
config.active_support.deprecation = :stderr
17-
18-
# Raises error for missing translations
19-
# config.action_view.raise_on_missing_translations = true
20-
2117
# Configure public file server for tests with Cache-Control for performance.
2218
config.public_file_server.enabled = true
2319
config.public_file_server.headers = {
24-
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
20+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
2521
}
2622

2723
# Show full error reports and disable caching.
2824
config.consider_all_requests_local = true
2925
config.action_controller.perform_caching = false
26+
config.cache_store = :null_store
3027

3128
# Raise exceptions instead of rendering exception templates.
3229
config.action_dispatch.show_exceptions = false
3330

3431
# Disable request forgery protection in test environment.
3532
config.action_controller.allow_forgery_protection = false
36-
# config.action_mailer.perform_caching = false
3733

38-
# Tell Action Mailer not to deliver emails to the real world.
39-
# The :test delivery method accumulates sent emails in the
40-
# ActionMailer::Base.deliveries array.
41-
# config.action_mailer.delivery_method = :test
34+
# Print deprecation notices to the stderr.
35+
config.active_support.deprecation = :stderr
4236

43-
config.public_file_server.enabled = true
37+
# Raises error for missing translations.
38+
# config.action_view.raise_on_missing_translations = true
4439
end
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Be sure to restart your server when you modify this file.
22

3-
# ApplicationController.renderer.defaults.merge!(
4-
# http_host: 'example.org',
5-
# https: false
6-
# )
3+
# ActiveSupport::Reloader.to_prepare do
4+
# ApplicationController.renderer.defaults.merge!(
5+
# http_host: 'example.org',
6+
# https: false
7+
# )
8+
# end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Be sure to restart your server when you modify this file.
2+
#
3+
# This file contains migration options to ease your Rails 6.0 upgrade.
4+
#
5+
# Once upgraded flip defaults one by one to migrate to the new default.
6+
#
7+
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
8+
9+
# Don't force requests from old versions of IE to be UTF-8 encoded.
10+
# Rails.application.config.action_view.default_enforce_utf8 = false
11+
12+
# Embed purpose and expiry metadata inside signed and encrypted
13+
# cookies for increased security.
14+
#
15+
# This option is not backwards compatible with earlier Rails versions.
16+
# It's best enabled when your entire app is migrated and stable on 6.0.
17+
# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
18+
19+
# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
20+
# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
21+
22+
# Return false instead of self when enqueuing is aborted from a callback.
23+
# Rails.application.config.active_job.return_false_on_aborted_enqueue = true
24+
25+
# Send Active Storage analysis and purge jobs to dedicated queues.
26+
# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
27+
# Rails.application.config.active_storage.queues.purge = :active_storage_purge
28+
29+
# When assigning to a collection of attachments declared via `has_many_attached`, replace existing
30+
# attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
31+
# Rails.application.config.active_storage.replace_on_assign_to_many = true
32+
33+
# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
34+
#
35+
# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
36+
# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
37+
# If you send mail in the background, job workers need to have a copy of
38+
# MailDeliveryJob to ensure all delivery jobs are processed properly.
39+
# Make sure your entire app is migrated and stable on 6.0 before using this setting.
40+
# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
41+
42+
# Enable the same cache key to be reused when the object being cached of type
43+
# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
44+
# of the relation's cache key into the cache version to support recycling cache key.
45+
# Rails.application.config.active_record.collection_cache_versioning = true

config/locales/en.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# 'true': 'foo'
2828
#
2929
# To learn more, please read the Rails Internationalization guide
30-
# available at http://guides.rubyonrails.org/i18n.html.
30+
# available at https://guides.rubyonrails.org/i18n.html.
3131

3232
en:
3333
hello: "Hello world"

0 commit comments

Comments
 (0)