Skip to content

Commit 1a86000

Browse files
committed
rails app:update
1 parent 1a63aa1 commit 1a86000

File tree

12 files changed

+144
-61
lines changed

12 files changed

+144
-61
lines changed

bin/brakeman

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env ruby
2+
require "rubygems"
3+
require "bundler/setup"
4+
5+
ARGV.unshift("--ensure-latest")
6+
7+
load Gem.bin_path("brakeman", "brakeman")

bin/rubocop

+8
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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env ruby
22
require "fileutils"
33

4-
# path to your application root.
54
APP_ROOT = File.expand_path("..", __dir__)
5+
APP_NAME = "coreui-pro-rails-starter"
66

77
def system!(*args)
88
system(*args, exception: true)
@@ -33,4 +33,8 @@ FileUtils.chdir APP_ROOT do
3333

3434
puts "\n== Restarting application server =="
3535
system! "bin/rails restart"
36+
37+
# puts "\n== Configuring puma-dev =="
38+
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
39+
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
3640
end

config/environments/development.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Show full error reports.
1515
config.consider_all_requests_local = true
1616

17-
# Enable server timing
17+
# Enable server timing.
1818
config.server_timing = true
1919

2020
# Enable/disable caching. By default caching is disabled.
@@ -24,9 +24,7 @@
2424
config.action_controller.enable_fragment_cache_logging = true
2525

2626
config.cache_store = :memory_store
27-
config.public_file_server.headers = {
28-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
29-
}
27+
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
3028
else
3129
config.action_controller.perform_caching = false
3230

@@ -39,8 +37,12 @@
3937
# Don't care if the mailer can't send.
4038
config.action_mailer.raise_delivery_errors = false
4139

40+
# Disable caching for Action Mailer templates even if Action Controller
41+
# caching is enabled.
4242
config.action_mailer.perform_caching = false
4343

44+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
45+
4446
# Print deprecation notices to the Rails logger.
4547
config.active_support.deprecation = :log
4648

@@ -61,21 +63,19 @@
6163

6264
# Suppress logger output for asset requests.
6365
config.assets.quiet = true
64-
65-
# required by devise, step 1
66-
config.action_mailer.default_url_options = {host: "localhost", port: 3000}
67-
6866
# Raises error for missing translations.
6967
# config.i18n.raise_on_missing_translations = true
7068

7169
# Annotate rendered view with file names.
72-
# config.action_view.annotate_rendered_view_with_filenames = true
70+
config.action_view.annotate_rendered_view_with_filenames = true
7371

7472
# Uncomment if you wish to allow Action Cable access from any origin.
7573
# config.action_cable.disable_request_forgery_protection = true
7674

77-
# Raise error when a before_action's only/except options reference missing actions
75+
# Raise error when a before_action's only/except options reference missing actions.
7876
config.action_controller.raise_on_missing_callback_actions = true
7977

78+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
79+
# config.generators.apply_rubocop_autocorrect_after_generate!
8080
config.hosts << "rails-starter.test"
8181
end

config/environments/production.rb

+12-13
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@
2020
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
2121
# config.require_master_key = true
2222

23-
# Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it).
24-
config.public_file_server.enabled = true
25-
26-
# Compress CSS using a preprocessor.
27-
# config.assets.css_compressor = :sass
28-
29-
# Do not fallback to assets pipeline if a precompiled asset is missed.
30-
config.assets.compile = false
23+
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
24+
# config.public_file_server.enabled = false
3125

3226
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3327
# config.asset_host = "http://assets.example.com"
@@ -51,15 +45,18 @@
5145
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
5246
config.force_ssl = true
5347

48+
# Skip http-to-https redirect for the default health check endpoint.
49+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
50+
5451
# Log to STDOUT by default
55-
config.logger = ActiveSupport::Logger.new($stdout)
56-
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
52+
config.logger = ActiveSupport::Logger.new(STDOUT)
53+
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
5754
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
5855

5956
# Prepend all log lines with the following tags.
60-
config.log_tags = [:request_id]
57+
config.log_tags = [ :request_id ]
6158

62-
# Info include generic and useful information about system operation, but avoids logging too much
59+
# "info" includes generic and useful information about system operation, but avoids logging too much
6360
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
6461
# want to log everything, set the level to "debug".
6562
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
@@ -68,9 +65,11 @@
6865
# config.cache_store = :mem_cache_store
6966

7067
# Use a real queuing backend for Active Job (and separate queues per environment).
71-
# config.active_job.queue_adapter = :resque
68+
# config.active_job.queue_adapter = :resque
7269
# config.active_job.queue_name_prefix = "coreui_pro_rails_starter_production"
7370

71+
# Disable caching for Action Mailer templates even if Action Controller
72+
# caching is enabled.
7473
config.action_mailer.perform_caching = false
7574

7675
# Ignore bad email addresses and do not raise email delivery errors.

config/environments/test.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,34 @@
1818
config.eager_load = ENV["CI"].present?
1919

2020
# Configure public file server for tests with Cache-Control for performance.
21-
config.public_file_server.enabled = true
22-
config.public_file_server.headers = {
23-
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
24-
}
21+
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
2522

2623
# Show full error reports and disable caching.
2724
config.consider_all_requests_local = true
2825
config.action_controller.perform_caching = false
2926
config.cache_store = :null_store
3027

31-
# Raise exceptions instead of rendering exception templates.
28+
# Render exception templates for rescuable exceptions and raise for other exceptions.
3229
config.action_dispatch.show_exceptions = :rescuable
3330

3431
# Disable request forgery protection in test environment.
3532
config.action_controller.allow_forgery_protection = false
3633

3734
# Store uploaded files on the local file system in a temporary directory.
3835
# config.active_storage.service = :test
39-
36+
# Disable caching for Action Mailer templates even if Action Controller
37+
# caching is enabled.
4038
config.action_mailer.perform_caching = false
4139

4240
# Tell Action Mailer not to deliver emails to the real world.
4341
# The :test delivery method accumulates sent emails in the
4442
# ActionMailer::Base.deliveries array.
4543
config.action_mailer.delivery_method = :test
4644

45+
# Unlike controllers, the mailer instance doesn't have any context about the
46+
# incoming request so you'll need to provide the :host parameter yourself.
47+
config.action_mailer.default_url_options = { host: "www.example.com" }
48+
4749
# Print deprecation notices to the stderr.
4850
config.active_support.deprecation = :stderr
4951

@@ -59,6 +61,6 @@
5961
# Annotate rendered view with file names.
6062
# config.action_view.annotate_rendered_view_with_filenames = true
6163

62-
# Raise error when a before_action's only/except options reference missing actions
64+
# Raise error when a before_action's only/except options reference missing actions.
6365
config.action_controller.raise_on_missing_callback_actions = true
6466
end

config/initializers/assets.rb

-5
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 << Rails.root.join("node_modules/@coreui/icons/sprites")
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 )

config/initializers/filter_parameter_logging.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Use this to limit dissemination of sensitive information.
55
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
66
Rails.application.config.filter_parameters += [
7-
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
7+
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
88
]

config/puma.rb

+23-24
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@
22
# are invoked here are part of Puma's configuration DSL. For more information
33
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
44

5-
# Puma can serve each request in a thread from an internal thread pool.
6-
# The `threads` method setting takes two numbers: a minimum and maximum.
7-
# Any libraries that use thread pools should be configured to match
8-
# the maximum value specified for Puma. Default is set to 5 threads for minimum
9-
# and maximum; this matches the default thread size of Active Record.
10-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
11-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
12-
threads min_threads_count, max_threads_count
13-
14-
# Specifies that the worker count should equal the number of processors in production.
15-
if ENV["RAILS_ENV"] == "production"
16-
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
17-
workers worker_count if worker_count > 1
18-
end
19-
20-
# Specifies the `worker_timeout` threshold that Puma will use to wait before
21-
# terminating a worker in development environments.
22-
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
5+
# Puma starts a configurable number of processes (workers) and each process
6+
# serves each request in a thread from an internal thread pool.
7+
#
8+
# The ideal number of threads per worker depends both on how much time the
9+
# application spends waiting for IO operations and on how much you wish to
10+
# to prioritize throughput over latency.
11+
#
12+
# As a rule of thumb, increasing the number of threads will increase how much
13+
# traffic a given process can handle (throughput), but due to CRuby's
14+
# Global VM Lock (GVL) it has diminishing returns and will degrade the
15+
# response time (latency) of the application.
16+
#
17+
# The default is set to 3 threads as it's deemed a decent compromise between
18+
# throughput and latency for the average Rails application.
19+
#
20+
# Any libraries that use a connection pool or another resource pool should
21+
# be configured to provide at least as many connections as the number of
22+
# threads. This includes Active Record's `pool` parameter in `database.yml`.
23+
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
24+
threads threads_count, threads_count
2325

2426
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
2527
port ENV.fetch("PORT", 3000)
2628

27-
# Specifies the `environment` that Puma will run in.
28-
environment ENV.fetch("RAILS_ENV") { "development" }
29-
30-
# Specifies the `pidfile` that Puma will use.
31-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
32-
3329
# Allow puma to be restarted by `bin/rails restart` command.
3430
plugin :tmp_restart
31+
32+
# Only use a pidfile when requested
33+
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]

public/406-unsupported-browser.html

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Your browser is not supported (406)</title>
5+
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<style>
7+
.rails-default-error-page {
8+
background-color: #EFEFEF;
9+
color: #2E2F30;
10+
text-align: center;
11+
font-family: arial, sans-serif;
12+
margin: 0;
13+
}
14+
15+
.rails-default-error-page div.dialog {
16+
width: 95%;
17+
max-width: 33em;
18+
margin: 4em auto 0;
19+
}
20+
21+
.rails-default-error-page div.dialog > div {
22+
border: 1px solid #CCC;
23+
border-right-color: #999;
24+
border-left-color: #999;
25+
border-bottom-color: #BBB;
26+
border-top: #B00100 solid 4px;
27+
border-top-left-radius: 9px;
28+
border-top-right-radius: 9px;
29+
background-color: white;
30+
padding: 7px 12% 0;
31+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32+
}
33+
34+
.rails-default-error-page h1 {
35+
font-size: 100%;
36+
color: #730E15;
37+
line-height: 1.5em;
38+
}
39+
40+
.rails-default-error-page div.dialog > p {
41+
margin: 0 0 1em;
42+
padding: 1em;
43+
background-color: #F7F7F7;
44+
border: 1px solid #CCC;
45+
border-right-color: #999;
46+
border-left-color: #999;
47+
border-bottom-color: #999;
48+
border-bottom-left-radius: 4px;
49+
border-bottom-right-radius: 4px;
50+
border-top-color: #DADADA;
51+
color: #666;
52+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53+
}
54+
</style>
55+
</head>
56+
57+
<body class="rails-default-error-page">
58+
<!-- This file lives in public/406-unsupported-browser.html -->
59+
<div class="dialog">
60+
<div>
61+
<h1>Your browser is not supported.</h1>
62+
<p>Please upgrade your browser to continue.</p>
63+
</div>
64+
</div>
65+
</body>
66+
</html>

public/icon.png

5.47 KB
Loading

public/icon.svg

+3
Loading

0 commit comments

Comments
 (0)