Skip to content

Commit d6fea56

Browse files
アップデートタスクを実行し、コンフリクトは上書き更新
1 parent ee20958 commit d6fea56

22 files changed

+807
-361
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/rubocop

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
require "rubygems"
3+
require "bundler/setup"
4+
5+
# explicit rubocop config increases performance slightly while avoiding config confusion.
6+
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
7+
8+
load Gem.bin_path("rubocop", "rubocop")

bin/setup

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env ruby
22
require "fileutils"
33

4-
# path to your application root.
54
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
@@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do
1413
# Add necessary setup steps to this file.
1514

1615
puts "== Installing dependencies =="
17-
system! "gem install bundler --conservative"
1816
system("bundle check") || system!("bundle install")
1917

2018
# puts "\n== Copying sample files =="
@@ -28,6 +26,9 @@ FileUtils.chdir APP_ROOT do
2826
puts "\n== Removing old logs and tempfiles =="
2927
system! "bin/rails log:clear tmp:clear"
3028

31-
puts "\n== Restarting application server =="
32-
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
3334
end

config/application.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class Application < Rails::Application
1111
# Initialize configuration defaults for originally generated Rails version.
1212
config.load_defaults 7.0
1313

14+
# Please, add to the `ignore` list any other `lib` subdirectories that do
15+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
16+
# Common ones are `templates`, `generators`, or `middleware`, for example.
17+
config.autoload_lib(ignore: %w[assets tasks])
18+
1419
# Configuration for the application, engines, and railties goes here.
1520
#
1621
# These settings can be overridden in specific environments using the files

config/environments/development.rb

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,82 +3,70 @@
33
Rails.application.configure do
44
# Settings specified here will take precedence over those in config/application.rb.
55

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

119
# Do not eager load code on boot.
1210
config.eager_load = false
1311

1412
# Show full error reports.
1513
config.consider_all_requests_local = true
1614

17-
# Enable server timing
15+
# Enable server timing.
1816
config.server_timing = true
1917

20-
# Add the following line to disable forgery_protection_origin_check
21-
config.action_controller.forgery_protection_origin_check = false
22-
23-
# Enable/disable caching. By default caching is disabled.
24-
# Run rails dev:cache to toggle caching.
18+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19+
# Run rails dev:cache to toggle Action Controller caching.
2520
if Rails.root.join("tmp/caching-dev.txt").exist?
2621
config.action_controller.perform_caching = true
2722
config.action_controller.enable_fragment_cache_logging = true
28-
29-
config.cache_store = :memory_store
30-
config.public_file_server.headers = {
31-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
32-
}
23+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
3324
else
3425
config.action_controller.perform_caching = false
35-
36-
config.cache_store = :null_store
3726
end
3827

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

4234
# Don't care if the mailer can't send.
4335
config.action_mailer.raise_delivery_errors = false
4436

37+
# Make template changes take effect immediately.
4538
config.action_mailer.perform_caching = false
4639

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

50-
# Raise exceptions for disallowed deprecations.
51-
config.active_support.disallowed_deprecation = :raise
52-
53-
# Tell Active Support which deprecation messages to disallow.
54-
config.active_support.disallowed_deprecation_warnings = []
55-
5646
# Raise an error on page load if there are pending migrations.
5747
config.active_record.migration_error = :page_load
5848

5949
# Highlight code that triggered database queries in logs.
6050
config.active_record.verbose_query_logs = true
6151

62-
# Suppress logger output for asset requests.
63-
config.assets.quiet = true
52+
# Append comments with runtime information tags to SQL queries in logs.
53+
config.active_record.query_log_tags_enabled = true
6454

65-
pf_domain = ENV['GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN']
66-
config.action_dispatch.default_headers = {
67-
'X-Frame-Options' => "ALLOW-FROM #{pf_domain}"
68-
}
55+
# Highlight code that enqueued background job in logs.
56+
config.active_job.verbose_enqueue_logs = true
6957

7058
# Raises error for missing translations.
7159
# config.i18n.raise_on_missing_translations = true
7260

7361
# Annotate rendered view with file names.
74-
# config.action_view.annotate_rendered_view_with_filenames = true
62+
config.action_view.annotate_rendered_view_with_filenames = true
7563

7664
# Uncomment if you wish to allow Action Cable access from any origin.
7765
# config.action_cable.disable_request_forgery_protection = true
7866

79-
# Allow requests from our preview domain.
80-
pf_host = "#{ENV['CODESPACE_NAME']}-3000.#{pf_domain}"
81-
config.hosts << pf_host
67+
# Raise error when a before_action's only/except options reference missing actions.
68+
config.action_controller.raise_on_missing_callback_actions = true
8269

83-
config.action_cable.allowed_request_origins = ["https://#{pf_host}"]
70+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
71+
# config.generators.apply_rubocop_autocorrect_after_generate!
8472
end

config/environments/production.rb

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,90 +4,86 @@
44
# Settings specified here will take precedence over those in config/application.rb.
55

66
# Code is not reloaded between requests.
7-
config.cache_classes = true
7+
config.enable_reloading = false
88

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

15-
# Full error reports are disabled and caching is turned on.
16-
config.consider_all_requests_local = false
17-
config.action_controller.perform_caching = true
18-
19-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21-
# config.require_master_key = true
22-
23-
# Disable serving static files from the `/public` folder by default since
24-
# Apache or NGINX already handles this.
25-
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
12+
# Full error reports are disabled.
13+
config.consider_all_requests_local = false
2614

27-
# Compress CSS using a preprocessor.
28-
# config.assets.css_compressor = :sass
15+
# Turn on fragment caching in view templates.
16+
config.action_controller.perform_caching = true
2917

30-
# Do not fallback to assets pipeline if a precompiled asset is missed.
31-
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}" }
3220

3321
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3422
# config.asset_host = "http://assets.example.com"
3523

36-
# Specifies the header that your server uses for sending files.
37-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
38-
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
39-
4024
# Store uploaded files on the local file system (see config/storage.yml for options).
4125
config.active_storage.service = :local
4226

43-
# Mount Action Cable outside main process or domain.
44-
# config.action_cable.mount_path = nil
45-
# config.action_cable.url = "wss://example.com/cable"
46-
# 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
4729

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

51-
# Include generic and useful information about system operation, but avoid logging too much
52-
# information to avoid inadvertent exposure of personally identifiable information (PII).
53-
config.log_level = :info
33+
# Skip http-to-https redirect for the default health check endpoint.
34+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
5435

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

58-
# Use a different cache store in production.
59-
# 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"
45+
46+
# Don't log any deprecations.
47+
config.active_support.report_deprecations = false
6048

61-
# Use a real queuing backend for Active Job (and separate queues per environment).
62-
# config.active_job.queue_adapter = :resque
63-
# config.active_job.queue_name_prefix = "codespaces_try_rails_production"
49+
# Replace the default in-process memory cache store with a durable alternative.
50+
# config.cache_store = :mem_cache_store
6451

65-
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
6654

6755
# Ignore bad email addresses and do not raise email delivery errors.
6856
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
6957
# config.action_mailer.raise_delivery_errors = false
7058

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+
7171
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
7272
# the I18n.default_locale when a translation cannot be found).
7373
config.i18n.fallbacks = true
7474

75-
# Don't log any deprecations.
76-
config.active_support.report_deprecations = false
77-
78-
# Use default logging formatter so that PID and timestamp are not suppressed.
79-
config.log_formatter = ::Logger::Formatter.new
80-
81-
# Use a different logger for distributed setups.
82-
# require "syslog/logger"
83-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
84-
85-
if ENV["RAILS_LOG_TO_STDOUT"].present?
86-
logger = ActiveSupport::Logger.new(STDOUT)
87-
logger.formatter = config.log_formatter
88-
config.logger = ActiveSupport::TaggedLogging.new(logger)
89-
end
90-
9175
# Do not dump schema after migrations.
9276
config.active_record.dump_schema_after_migration = false
77+
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+
# ]
86+
#
87+
# Skip DNS rebinding protection for the default health check endpoint.
88+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
9389
end

config/environments/test.rb

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require "active_support/core_ext/integer/time"
2-
31
# The test environment is used exclusively to run your application's
42
# test suite. You never need to work with it otherwise. Remember that
53
# your test database is "scratch space" for the test suite and is wiped
@@ -8,53 +6,48 @@
86
Rails.application.configure do
97
# Settings specified here will take precedence over those in config/application.rb.
108

11-
# Turn false under Spring and add config.action_view.cache_template_loading = true.
12-
config.cache_classes = true
9+
# While tests run files are not watched, reloading is not necessary.
10+
config.enable_reloading = false
1311

14-
# Eager loading loads your whole application. When running a single test locally,
15-
# this probably isn't necessary. It's a good idea to do in a continuous integration
16-
# system, or in some way before deploying your code.
12+
# Eager loading loads your entire application. When running a single test locally,
13+
# this is usually not necessary, and can slow down your test suite. However, it's
14+
# recommended that you enable it in continuous integration systems to ensure eager
15+
# loading is working properly before deploying your code.
1716
config.eager_load = ENV["CI"].present?
1817

19-
# Configure public file server for tests with Cache-Control for performance.
20-
config.public_file_server.enabled = true
21-
config.public_file_server.headers = {
22-
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
23-
}
18+
# Configure public file server for tests with cache-control for performance.
19+
config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
2420

25-
# Show full error reports and disable caching.
26-
config.consider_all_requests_local = true
27-
config.action_controller.perform_caching = false
21+
# Show full error reports.
22+
config.consider_all_requests_local = true
2823
config.cache_store = :null_store
2924

30-
# Raise exceptions instead of rendering exception templates.
31-
config.action_dispatch.show_exceptions = false
25+
# Render exception templates for rescuable exceptions and raise for other exceptions.
26+
config.action_dispatch.show_exceptions = :rescuable
3227

3328
# Disable request forgery protection in test environment.
3429
config.action_controller.allow_forgery_protection = false
3530

3631
# Store uploaded files on the local file system in a temporary directory.
3732
config.active_storage.service = :test
3833

39-
config.action_mailer.perform_caching = false
40-
4134
# Tell Action Mailer not to deliver emails to the real world.
4235
# The :test delivery method accumulates sent emails in the
4336
# ActionMailer::Base.deliveries array.
4437
config.action_mailer.delivery_method = :test
4538

39+
# Set host to be used by links generated in mailer templates.
40+
config.action_mailer.default_url_options = { host: "example.com" }
41+
4642
# Print deprecation notices to the stderr.
4743
config.active_support.deprecation = :stderr
4844

49-
# Raise exceptions for disallowed deprecations.
50-
config.active_support.disallowed_deprecation = :raise
51-
52-
# Tell Active Support which deprecation messages to disallow.
53-
config.active_support.disallowed_deprecation_warnings = []
54-
5545
# Raises error for missing translations.
5646
# config.i18n.raise_on_missing_translations = true
5747

5848
# Annotate rendered view with file names.
5949
# config.action_view.annotate_rendered_view_with_filenames = true
50+
51+
# Raise error when a before_action's only/except options reference missing actions.
52+
config.action_controller.raise_on_missing_callback_actions = true
6053
end

config/initializers/assets.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@
55

66
# Add additional assets to the asset load path.
77
# Rails.application.config.assets.paths << Emoji.images_path
8-
9-
# Precompile additional assets.
10-
# application.js, application.css, and all non-JS/CSS in the app/assets
11-
# folder are already added.
12-
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

0 commit comments

Comments
 (0)