Skip to content

Commit cf8ea54

Browse files
committed
rails app:update
1 parent 1209603 commit cf8ea54

12 files changed

+121
-36
lines changed

bin/setup

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env ruby
22
require 'fileutils'
3-
include FileUtils
43

54
# path to your application root.
65
APP_ROOT = File.expand_path('..', __dir__)
@@ -9,24 +8,25 @@ def system!(*args)
98
system(*args) || abort("\n== Command #{args} failed ==")
109
end
1110

12-
chdir APP_ROOT do
13-
# 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.
1414
# Add necessary setup steps to this file.
1515

1616
puts '== Installing dependencies =='
1717
system! 'gem install bundler --conservative'
1818
system('bundle check') || system!('bundle install')
1919

20-
# Install JavaScript dependencies if using Yarn
20+
# Install JavaScript dependencies
2121
# system('bin/yarn')
2222

2323
# puts "\n== Copying sample files =="
2424
# unless File.exist?('config/database.yml')
25-
# cp 'config/database.yml.sample', 'config/database.yml'
25+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
2626
# end
2727

2828
puts "\n== Preparing database =="
29-
system! 'bin/rails db:setup'
29+
system! 'bin/rails db:prepare'
3030

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

config/cable.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ development:
22
adapter: async
33

44
test:
5-
adapter: async
5+
adapter: test
66

77
production:
88
adapter: redis

config/environments/development.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# Run rails dev:cache to toggle caching.
1717
if Rails.root.join('tmp', 'caching-dev.txt').exist?
1818
config.action_controller.perform_caching = true
19+
config.action_controller.enable_fragment_cache_logging = true
1920

2021
config.cache_store = :memory_store
2122
config.public_file_server.headers = {
@@ -27,7 +28,7 @@
2728
config.cache_store = :null_store
2829
end
2930

30-
# Store uploaded files on the local file system (see config/storage.yml for options)
31+
# Store uploaded files on the local file system (see config/storage.yml for options).
3132
config.active_storage.service = :local
3233

3334
# Don't care if the mailer can't send.
@@ -52,7 +53,7 @@
5253
# Suppress logger output for asset requests.
5354
config.assets.quiet = true
5455

55-
# Raises error for missing translations
56+
# Raises error for missing translations.
5657
# config.action_view.raise_on_missing_translations = true
5758

5859
# Use an evented file watcher to asynchronously detect changes in source code,

config/environments/production.rb

+26-8
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,23 @@
2222
# Apache or NGINX already handles this.
2323
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
2424

25-
# Compress JavaScripts and CSS.
26-
config.assets.js_compressor = :uglifier
25+
# Compress CSS using a preprocessor.
2726
# config.assets.css_compressor = :sass
2827

2928
# Do not fallback to assets pipeline if a precompiled asset is missed.
3029
config.assets.compile = false
3130

32-
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
33-
3431
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3532
# config.action_controller.asset_host = 'http://assets.example.com'
3633

3734
# Specifies the header that your server uses for sending files.
3835
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
3936
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
4037

41-
# Store uploaded files on the local file system (see config/storage.yml for options)
38+
# Store uploaded files on the local file system (see config/storage.yml for options).
4239
config.active_storage.service = :local
4340

44-
# Mount Action Cable outside main process or domain
41+
# Mount Action Cable outside main process or domain.
4542
# config.action_cable.mount_path = nil
4643
# config.action_cable.url = 'wss://example.com/cable'
4744
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
@@ -59,9 +56,9 @@
5956
# Use a different cache store in production.
6057
# config.cache_store = :mem_cache_store
6158

62-
# Use a real queuing backend for Active Job (and separate queues per environment)
59+
# Use a real queuing backend for Active Job (and separate queues per environment).
6360
# config.active_job.queue_adapter = :resque
64-
# config.active_job.queue_name_prefix = "medireco_#{Rails.env}"
61+
# config.active_job.queue_name_prefix = "medireco_production"
6562

6663
config.action_mailer.perform_caching = false
6764

@@ -91,4 +88,25 @@
9188

9289
# Do not dump schema after migrations.
9390
config.active_record.dump_schema_after_migration = false
91+
92+
# Inserts middleware to perform automatic connection switching.
93+
# The `database_selector` hash is used to pass options to the DatabaseSelector
94+
# middleware. The `delay` is used to determine how long to wait after a write
95+
# to send a subsequent read to the primary.
96+
#
97+
# The `database_resolver` class is used by the middleware to determine which
98+
# database is appropriate to use based on the time delay.
99+
#
100+
# The `database_resolver_context` class is used by the middleware to set
101+
# timestamps for the last write to the primary. The resolver uses the context
102+
# class timestamps to determine how long to wait before reading from the
103+
# replica.
104+
#
105+
# By default Rails will store a last write timestamp in the session. The
106+
# DatabaseSelector middleware is designed as such you can define your own
107+
# strategy for connection switching and pass that into the middleware through
108+
# these configuration options.
109+
# config.active_record.database_selector = { delay: 2.seconds }
110+
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
111+
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
94112
end

config/environments/test.rb

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
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
@@ -21,14 +23,15 @@
2123
# Show full error reports and disable caching.
2224
config.consider_all_requests_local = true
2325
config.action_controller.perform_caching = false
26+
config.cache_store = :null_store
2427

2528
# Raise exceptions instead of rendering exception templates.
2629
config.action_dispatch.show_exceptions = false
2730

2831
# Disable request forgery protection in test environment.
2932
config.action_controller.allow_forgery_protection = false
3033

31-
# Store uploaded files on the local file system in a temporary directory
34+
# Store uploaded files on the local file system in a temporary directory.
3235
config.active_storage.service = :test
3336

3437
config.action_mailer.perform_caching = false
@@ -41,6 +44,6 @@
4144
# Print deprecation notices to the stderr.
4245
config.active_support.deprecation = :stderr
4346

44-
# Raises error for missing translations
47+
# Raises error for missing translations.
4548
# config.action_view.raise_on_missing_translations = true
4649
end

config/initializers/content_security_policy.rb

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# policy.object_src :none
1212
# policy.script_src :self, :https
1313
# policy.style_src :self, :https
14+
# # If you are using webpack-dev-server then specify webpack-dev-server host
15+
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
1416

1517
# # Specify URI for violation reports
1618
# # policy.report_uri "/csp-violation-report-endpoint"
@@ -19,6 +21,9 @@
1921
# If you are using UJS then enable automatic nonce generation
2022
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
2123

24+
# Set the nonce only to specific directives
25+
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
26+
2227
# Report CSP violations to a specified URI
2328
# For further information see the following documentation:
2429
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
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"

config/puma.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
# the maximum value specified for Puma. Default is set to 5 threads for minimum
55
# and maximum; this matches the default thread size of Active Record.
66
#
7-
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8-
threads threads_count, threads_count
7+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9+
threads min_threads_count, max_threads_count
910

1011
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
1112
#
@@ -15,8 +16,11 @@
1516
#
1617
environment ENV.fetch("RAILS_ENV") { "development" }
1718

19+
# Specifies the `pidfile` that Puma will use.
20+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
21+
1822
# Specifies the number of `workers` to boot in clustered mode.
19-
# Workers are forked webserver processes. If using threads and workers together
23+
# Workers are forked web server processes. If using threads and workers together
2024
# the concurrency of the application would be max `threads` * `workers`.
2125
# Workers do not work on JRuby or Windows (both of which do not support
2226
# processes).

config/routes.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
2-
31
Rails.application.routes.draw do
2+
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
43
root to: 'home#index'
54

65
resources :medical_bills, except: :show

config/spring.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%w[
2-
.ruby-version
3-
.rbenv-vars
4-
tmp/restart.txt
5-
tmp/caching-dev.txt
6-
].each { |path| Spring.watch(path) }
1+
Spring.watch(
2+
".ruby-version",
3+
".rbenv-vars",
4+
"tmp/restart.txt",
5+
"tmp/caching-dev.txt"
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This migration comes from active_storage (originally 20180723000244)
2+
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
3+
def up
4+
return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
5+
6+
if table_exists?(:active_storage_blobs)
7+
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
8+
end
9+
end
10+
end

0 commit comments

Comments
 (0)