Skip to content

Commit 504272c

Browse files
committed
rails app:update, rails db:migrate
1 parent 4a25d03 commit 504272c

25 files changed

+839
-455
lines changed

bin/dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env ruby
2+
exec "./bin/rails", "server", *ARGV

bin/rails

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
#!/usr/bin/env ruby
2-
begin
3-
load File.expand_path('../spring', __FILE__)
4-
rescue LoadError => e
5-
raise unless e.message.include?('spring')
6-
end
7-
APP_PATH = File.expand_path('../config/application', __dir__)
8-
require_relative '../config/boot'
9-
require 'rails/commands'
2+
APP_PATH = File.expand_path("../config/application", __dir__)
3+
require_relative "../config/boot"
4+
require "rails/commands"

bin/rake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
#!/usr/bin/env ruby
2-
begin
3-
load File.expand_path('../spring', __FILE__)
4-
rescue LoadError => e
5-
raise unless e.message.include?('spring')
6-
end
7-
require_relative '../config/boot'
8-
require 'rake'
2+
require_relative "../config/boot"
3+
require "rake"
94
Rake.application.run

bin/setup

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
#!/usr/bin/env ruby
2-
require 'fileutils'
2+
require "fileutils"
33

4-
# path to your application root.
5-
APP_ROOT = File.expand_path('..', __dir__)
4+
APP_ROOT = File.expand_path("..", __dir__)
65

76
def system!(*args)
8-
system(*args) || abort("\n== Command #{args} failed ==")
7+
system(*args, exception: true)
98
end
109

1110
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.
11+
# This script is a way to set up or update your development environment automatically.
12+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
1413
# Add necessary setup steps to this file.
1514

16-
puts '== Installing dependencies =='
17-
system! 'gem install bundler --conservative'
18-
system('bundle check') || system!('bundle install')
19-
20-
# Install JavaScript dependencies
21-
# system('bin/yarn')
15+
puts "== Installing dependencies =="
16+
system("bundle check") || system!("bundle install")
2217

2318
# puts "\n== Copying sample files =="
24-
# unless File.exist?('config/database.yml')
25-
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
19+
# unless File.exist?("config/database.yml")
20+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
2621
# end
2722

2823
puts "\n== Preparing database =="
29-
system! 'bin/rails db:prepare'
24+
system! "bin/rails db:prepare"
3025

3126
puts "\n== Removing old logs and tempfiles =="
32-
system! 'bin/rails log:clear tmp:clear'
27+
system! "bin/rails log:clear tmp:clear"
3328

34-
puts "\n== Restarting application server =="
35-
system! 'bin/rails restart'
29+
unless ARGV.include?("--skip-server")
30+
puts "\n== Starting development server =="
31+
STDOUT.flush # flush the output before exec(2) so that it displays
32+
exec "bin/dev"
33+
end
3634
end

config/application.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative 'boot'
1+
require_relative "boot"
22

33
require "rails"
44
# Pick the frameworks you want:
@@ -12,7 +12,6 @@
1212
require "action_text/engine"
1313
require "action_view/railtie"
1414
require "action_cable/engine"
15-
require "sprockets/railtie"
1615
# require "rails/test_unit/railtie"
1716

1817
# Require the gems listed in Gemfile, including any gems
@@ -24,10 +23,18 @@ class Application < Rails::Application
2423
# Initialize configuration defaults for originally generated Rails version.
2524
config.load_defaults 6.0
2625

27-
# Settings in config/environments/* take precedence over those specified here.
28-
# Application configuration can go into files in config/initializers
29-
# -- all .rb files in that directory are automatically loaded after loading
30-
# the framework and any gems in your application.
26+
# Please, add to the `ignore` list any other `lib` subdirectories that do
27+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
28+
# Common ones are `templates`, `generators`, or `middleware`, for example.
29+
config.autoload_lib(ignore: %w[assets tasks])
30+
31+
# Configuration for the application, engines, and railties goes here.
32+
#
33+
# These settings can be overridden in specific environments using the files
34+
# in config/environments, which are processed later.
35+
#
36+
# config.time_zone = "Central Time (US & Canada)"
37+
# config.eager_load_paths << Rails.root.join("extras")
3138

3239
# Don't generate system test files.
3340
config.generators.system_tests = nil

config/boot.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
1+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
22

3-
require 'bundler/setup' # Set up gems listed in the Gemfile.
4-
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
3+
require "bundler/setup" # Set up gems listed in the Gemfile.
4+
require "bootsnap/setup" # Speed up boot time by caching expensive operations.

config/environment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Load the Rails application.
2-
require_relative 'application'
2+
require_relative "application"
33

44
# Initialize the Rails application.
55
Rails.application.initialize!

config/environments/development.rb

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
1+
require "active_support/core_ext/integer/time"
2+
13
Rails.application.configure do
24
# Settings specified here will take precedence over those in config/application.rb.
35

4-
# In the development environment your application's code is reloaded on
5-
# every request. This slows down response time but is perfect for development
6-
# since you don't have to restart the web server when you make code changes.
7-
config.cache_classes = false
6+
# Make code changes take effect immediately without server restart.
7+
config.enable_reloading = true
88

99
# Do not eager load code on boot.
1010
config.eager_load = false
1111

1212
# Show full error reports.
1313
config.consider_all_requests_local = true
1414

15-
# Enable/disable caching. By default caching is disabled.
16-
# Run rails dev:cache to toggle caching.
17-
if Rails.root.join('tmp', 'caching-dev.txt').exist?
15+
# Enable server timing.
16+
config.server_timing = true
17+
18+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19+
# Run rails dev:cache to toggle Action Controller caching.
20+
if Rails.root.join("tmp/caching-dev.txt").exist?
1821
config.action_controller.perform_caching = true
1922
config.action_controller.enable_fragment_cache_logging = true
20-
21-
config.cache_store = :memory_store
22-
config.public_file_server.headers = {
23-
'Cache-Control' => "public, max-age=#{2.days.to_i}"
24-
}
23+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
2524
else
2625
config.action_controller.perform_caching = false
27-
28-
config.cache_store = :null_store
2926
end
3027

28+
# Change to :null_store to avoid any caching.
29+
config.cache_store = :memory_store
30+
3131
# Store uploaded files on the local file system (see config/storage.yml for options).
32-
config.active_storage.service = :cloudinary
32+
config.active_storage.service = :local
3333

3434
# Don't care if the mailer can't send.
3535
config.action_mailer.raise_delivery_errors = false
3636

37+
# Make template changes take effect immediately.
3738
config.action_mailer.perform_caching = false
3839

40+
# Set localhost to be used by links generated in mailer templates.
41+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
42+
3943
# Print deprecation notices to the Rails logger.
4044
config.active_support.deprecation = :log
4145

@@ -45,21 +49,21 @@
4549
# Highlight code that triggered database queries in logs.
4650
config.active_record.verbose_query_logs = true
4751

48-
# Debug mode disables concatenation and preprocessing of assets.
49-
# This option may cause significant delays in view rendering with a large
50-
# number of complex assets.
51-
config.assets.debug = true
52+
# Append comments with runtime information tags to SQL queries in logs.
53+
config.active_record.query_log_tags_enabled = true
5254

53-
# Suppress logger output for asset requests.
54-
config.assets.quiet = true
55+
# Highlight code that enqueued background job in logs.
56+
config.active_job.verbose_enqueue_logs = true
5557

5658
# Raises error for missing translations.
57-
# config.action_view.raise_on_missing_translations = true
59+
# config.i18n.raise_on_missing_translations = true
60+
61+
# Annotate rendered view with file names.
62+
config.action_view.annotate_rendered_view_with_filenames = true
5863

59-
# Use an evented file watcher to asynchronously detect changes in source code,
60-
# routes, locales, etc. This feature depends on the listen gem.
61-
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
64+
# Uncomment if you wish to allow Action Cable access from any origin.
65+
# config.action_cable.disable_request_forgery_protection = true
6266

63-
# Config perso
64-
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
67+
# Raise error when a before_action's only/except options reference missing actions.
68+
config.action_controller.raise_on_missing_callback_actions = true
6569
end

config/environments/production.rb

Lines changed: 53 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,89 @@
1+
require "active_support/core_ext/integer/time"
2+
13
Rails.application.configure do
24
# Settings specified here will take precedence over those in config/application.rb.
35

46
# Code is not reloaded between requests.
5-
config.cache_classes = true
7+
config.enable_reloading = false
68

7-
# Eager load code on boot. This eager loads most of Rails and
8-
# your application in memory, allowing both threaded web servers
9-
# and those relying on copy on write to perform better.
10-
# Rake tasks automatically ignore this option for performance.
9+
# Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
1110
config.eager_load = true
1211

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
12+
# Full error reports are disabled.
13+
config.consider_all_requests_local = false
2014

21-
# Disable serving static files from the `/public` folder by default since
22-
# Apache or NGINX already handles this.
23-
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
24-
25-
# Compress CSS using a preprocessor.
26-
# config.assets.css_compressor = :sass
15+
# Turn on fragment caching in view templates.
16+
config.action_controller.perform_caching = true
2717

28-
# Do not fallback to assets pipeline if a precompiled asset is missed.
29-
config.assets.compile = false
18+
# Cache assets for far-future expiry since they are all digest stamped.
19+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
3020

3121
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
32-
# config.action_controller.asset_host = 'http://assets.example.com'
33-
34-
# Specifies the header that your server uses for sending files.
35-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
36-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
22+
# config.asset_host = "http://assets.example.com"
3723

3824
# Store uploaded files on the local file system (see config/storage.yml for options).
39-
config.active_storage.service = :cloudinary
25+
config.active_storage.service = :local
4026

41-
# Mount Action Cable outside main process or domain.
42-
# config.action_cable.mount_path = nil
43-
# config.action_cable.url = 'wss://example.com/cable'
44-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
27+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
28+
config.assume_ssl = true
4529

4630
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
47-
# config.force_ssl = true
31+
config.force_ssl = true
4832

49-
# Use the lowest log level to ensure availability of diagnostic information
50-
# when problems arise.
51-
config.log_level = :debug
33+
# Skip http-to-https redirect for the default health check endpoint.
34+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
5235

53-
# Prepend all log lines with the following tags.
36+
# Log to STDOUT with the current request id as a default log tag.
5437
config.log_tags = [ :request_id ]
38+
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
5539

56-
# Use a different cache store in production.
57-
# config.cache_store = :mem_cache_store
40+
# Change to "debug" to log everything (including potentially personally-identifiable information!)
41+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
42+
43+
# Prevent health checks from clogging up the logs.
44+
config.silence_healthcheck_path = "/up"
5845

59-
# Use a real queuing backend for Active Job (and separate queues per environment).
60-
# config.active_job.queue_adapter = :resque
61-
# config.active_job.queue_name_prefix = "rails_watch_list_production"
46+
# Don't log any deprecations.
47+
config.active_support.report_deprecations = false
48+
49+
# Replace the default in-process memory cache store with a durable alternative.
50+
# config.cache_store = :mem_cache_store
6251

63-
config.action_mailer.perform_caching = false
52+
# Replace the default in-process and non-durable queuing backend for Active Job.
53+
# config.active_job.queue_adapter = :resque
6454

6555
# Ignore bad email addresses and do not raise email delivery errors.
6656
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
6757
# config.action_mailer.raise_delivery_errors = false
6858

59+
# Set host to be used by links generated in mailer templates.
60+
config.action_mailer.default_url_options = { host: "example.com" }
61+
62+
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
63+
# config.action_mailer.smtp_settings = {
64+
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
65+
# password: Rails.application.credentials.dig(:smtp, :password),
66+
# address: "smtp.example.com",
67+
# port: 587,
68+
# authentication: :plain
69+
# }
70+
6971
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
7072
# the I18n.default_locale when a translation cannot be found).
7173
config.i18n.fallbacks = true
7274

73-
# Send deprecation notices to registered listeners.
74-
config.active_support.deprecation = :notify
75-
76-
# Use default logging formatter so that PID and timestamp are not suppressed.
77-
config.log_formatter = ::Logger::Formatter.new
78-
79-
# Use a different logger for distributed setups.
80-
# require 'syslog/logger'
81-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82-
83-
if ENV["RAILS_LOG_TO_STDOUT"].present?
84-
logger = ActiveSupport::Logger.new(STDOUT)
85-
logger.formatter = config.log_formatter
86-
config.logger = ActiveSupport::TaggedLogging.new(logger)
87-
end
88-
8975
# Do not dump schema after migrations.
9076
config.active_record.dump_schema_after_migration = false
9177

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.
78+
# Only use :id for inspections in production.
79+
config.active_record.attributes_for_inspect = [ :id ]
80+
81+
# Enable DNS rebinding protection and other `Host` header attacks.
82+
# config.hosts = [
83+
# "example.com", # Allow requests from example.com
84+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
85+
# ]
10486
#
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
112-
113-
config.action_mailer.default_url_options = { host: 'https://rzt-rails-watch-list.herokuapp.com/' }
114-
# config.action_mailer.default_url_options = { host: 'https://rzt-rails-watch-list.herokuapp.com/', port: 80 }
87+
# Skip DNS rebinding protection for the default health check endpoint.
88+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
11589
end

0 commit comments

Comments
 (0)