Skip to content

Commit a839589

Browse files
committed
rails 6
1 parent d0aca86 commit a839589

16 files changed

+297
-89
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ git_source(:github) do |repo_name|
66
"https://github.com/#{repo_name}.git"
77
end
88

9-
gem 'rails', '~> 5.2.0'
9+
gem 'rails', '~> 6.0.0'
1010

1111
gem 'activeadmin'
1212
gem 'bootsnap', require: false

Gemfile.lock

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,42 @@ GIT
99
GEM
1010
remote: https://rubygems.org/
1111
specs:
12-
actioncable (5.2.4.4)
13-
actionpack (= 5.2.4.4)
12+
actioncable (6.0.3.4)
13+
actionpack (= 6.0.3.4)
1414
nio4r (~> 2.0)
1515
websocket-driver (>= 0.6.1)
16-
actionmailer (5.2.4.4)
17-
actionpack (= 5.2.4.4)
18-
actionview (= 5.2.4.4)
19-
activejob (= 5.2.4.4)
16+
actionmailbox (6.0.3.4)
17+
actionpack (= 6.0.3.4)
18+
activejob (= 6.0.3.4)
19+
activerecord (= 6.0.3.4)
20+
activestorage (= 6.0.3.4)
21+
activesupport (= 6.0.3.4)
22+
mail (>= 2.7.1)
23+
actionmailer (6.0.3.4)
24+
actionpack (= 6.0.3.4)
25+
actionview (= 6.0.3.4)
26+
activejob (= 6.0.3.4)
2027
mail (~> 2.5, >= 2.5.4)
2128
rails-dom-testing (~> 2.0)
22-
actionpack (5.2.4.4)
23-
actionview (= 5.2.4.4)
24-
activesupport (= 5.2.4.4)
29+
actionpack (6.0.3.4)
30+
actionview (= 6.0.3.4)
31+
activesupport (= 6.0.3.4)
2532
rack (~> 2.0, >= 2.0.8)
2633
rack-test (>= 0.6.3)
2734
rails-dom-testing (~> 2.0)
28-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
29-
actionview (5.2.4.4)
30-
activesupport (= 5.2.4.4)
35+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
36+
actiontext (6.0.3.4)
37+
actionpack (= 6.0.3.4)
38+
activerecord (= 6.0.3.4)
39+
activestorage (= 6.0.3.4)
40+
activesupport (= 6.0.3.4)
41+
nokogiri (>= 1.8.5)
42+
actionview (6.0.3.4)
43+
activesupport (= 6.0.3.4)
3144
builder (~> 3.1)
3245
erubi (~> 1.4)
3346
rails-dom-testing (~> 2.0)
34-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
47+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
3548
activeadmin (2.9.0)
3649
arbre (~> 1.2, >= 1.2.1)
3750
formtastic (>= 3.1, < 5.0)
@@ -41,31 +54,31 @@ GEM
4154
kaminari (~> 1.0, >= 1.2.1)
4255
railties (>= 5.2, < 6.2)
4356
ransack (~> 2.1, >= 2.1.1)
44-
activejob (5.2.4.4)
45-
activesupport (= 5.2.4.4)
57+
activejob (6.0.3.4)
58+
activesupport (= 6.0.3.4)
4659
globalid (>= 0.3.6)
47-
activemodel (5.2.4.4)
48-
activesupport (= 5.2.4.4)
49-
activerecord (5.2.4.4)
50-
activemodel (= 5.2.4.4)
51-
activesupport (= 5.2.4.4)
52-
arel (>= 9.0)
53-
activestorage (5.2.4.4)
54-
actionpack (= 5.2.4.4)
55-
activerecord (= 5.2.4.4)
60+
activemodel (6.0.3.4)
61+
activesupport (= 6.0.3.4)
62+
activerecord (6.0.3.4)
63+
activemodel (= 6.0.3.4)
64+
activesupport (= 6.0.3.4)
65+
activestorage (6.0.3.4)
66+
actionpack (= 6.0.3.4)
67+
activejob (= 6.0.3.4)
68+
activerecord (= 6.0.3.4)
5669
marcel (~> 0.3.1)
57-
activesupport (5.2.4.4)
70+
activesupport (6.0.3.4)
5871
concurrent-ruby (~> 1.0, >= 1.0.2)
5972
i18n (>= 0.7, < 2)
6073
minitest (~> 5.1)
6174
tzinfo (~> 1.1)
75+
zeitwerk (~> 2.2, >= 2.2.2)
6276
addressable (2.7.0)
6377
public_suffix (>= 2.0.2, < 5.0)
6478
analytics-ruby (2.2.8)
6579
arbre (1.4.0)
6680
activesupport (>= 3.0.0, < 6.2)
6781
ruby2_keywords (>= 0.0.2, < 1.0)
68-
arel (9.0.0)
6982
autoprefixer-rails (10.1.0.0)
7083
execjs
7184
awesome_print (1.8.0)
@@ -217,30 +230,32 @@ GEM
217230
rack (~> 2.0)
218231
rack-test (1.1.0)
219232
rack (>= 1.0, < 3)
220-
rails (5.2.4.4)
221-
actioncable (= 5.2.4.4)
222-
actionmailer (= 5.2.4.4)
223-
actionpack (= 5.2.4.4)
224-
actionview (= 5.2.4.4)
225-
activejob (= 5.2.4.4)
226-
activemodel (= 5.2.4.4)
227-
activerecord (= 5.2.4.4)
228-
activestorage (= 5.2.4.4)
229-
activesupport (= 5.2.4.4)
233+
rails (6.0.3.4)
234+
actioncable (= 6.0.3.4)
235+
actionmailbox (= 6.0.3.4)
236+
actionmailer (= 6.0.3.4)
237+
actionpack (= 6.0.3.4)
238+
actiontext (= 6.0.3.4)
239+
actionview (= 6.0.3.4)
240+
activejob (= 6.0.3.4)
241+
activemodel (= 6.0.3.4)
242+
activerecord (= 6.0.3.4)
243+
activestorage (= 6.0.3.4)
244+
activesupport (= 6.0.3.4)
230245
bundler (>= 1.3.0)
231-
railties (= 5.2.4.4)
246+
railties (= 6.0.3.4)
232247
sprockets-rails (>= 2.0.0)
233248
rails-dom-testing (2.0.3)
234249
activesupport (>= 4.2.0)
235250
nokogiri (>= 1.6)
236251
rails-html-sanitizer (1.3.0)
237252
loofah (~> 2.3)
238-
railties (5.2.4.4)
239-
actionpack (= 5.2.4.4)
240-
activesupport (= 5.2.4.4)
253+
railties (6.0.3.4)
254+
actionpack (= 6.0.3.4)
255+
activesupport (= 6.0.3.4)
241256
method_source
242257
rake (>= 0.8.7)
243-
thor (>= 0.19.0, < 2.0)
258+
thor (>= 0.20.3, < 2.0)
244259
rake (13.0.3)
245260
ransack (2.4.1)
246261
activerecord (>= 5.2.4)
@@ -376,6 +391,7 @@ GEM
376391
websocket-extensions (0.1.5)
377392
xpath (3.2.0)
378393
nokogiri (~> 1.8)
394+
zeitwerk (2.4.2)
379395

380396
PLATFORMS
381397
ruby
@@ -405,7 +421,7 @@ DEPENDENCIES
405421
puma
406422
pundit
407423
rack-attack
408-
rails (~> 5.2.0)
424+
rails (~> 6.0.0)
409425
redis-rails
410426
rollbar
411427
rspec-its

config/application.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@
88

99
module RailsBase
1010
class Application < Rails::Application
11-
config.middleware.use Rack::Attack
12-
1311
config.active_job.queue_adapter = :sidekiq
1412
config.active_job.queue_name_prefix = "rails5_#{Rails.env}"
1513

1614
config.stripe.secret_key = ENV['STRIPE_SECRET_KEY']
1715
config.stripe.publishable_key = ENV['STRIPE_PUBLISHABLE_KEY']
1816

1917
# Settings in config/environments/* take precedence over those specified here.
20-
# Application configuration should go into files in config/initializers
21-
# -- all .rb files in that directory are automatically loaded.
22-
2318
# NOTE: please update for PROD
2419
config.action_mailer.default_url_options = { :host => 'localhost' }
2520

@@ -33,5 +28,9 @@ class Application < Rails::Application
3328
g.view_specs false
3429
g.helper_specs false
3530
end
31+
32+
# Application configuration can go into files in config/initializers
33+
# -- all .rb files in that directory are automatically loaded after loading
34+
# the framework and any gems in your application.
3635
end
3736
end

config/cable.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ development:
22
adapter: async
33

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

77
production:
88
adapter: redis
9-
url: redis://localhost:6379/1
9+
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10+
channel_prefix: rails_base_production

config/environments/development.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,24 @@
1313
config.consider_all_requests_local = true
1414

1515
# Enable/disable caching. By default caching is disabled.
16-
if Rails.root.join('tmp/caching-dev.txt').exist?
16+
# Run rails dev:cache to toggle caching.
17+
if Rails.root.join('tmp', 'caching-dev.txt').exist?
1718
config.action_controller.perform_caching = true
19+
config.action_controller.enable_fragment_cache_logging = true
1820

1921
config.cache_store = :memory_store
2022
config.public_file_server.headers = {
21-
'Cache-Control' => 'public, max-age=172800'
23+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
2224
}
2325
else
2426
config.action_controller.perform_caching = false
2527

2628
config.cache_store = :null_store
2729
end
2830

31+
# Store uploaded files on the local file system (see config/storage.yml for options).
32+
config.active_storage.service = :local
33+
2934
# Don't care if the mailer can't send.
3035
config.action_mailer.raise_delivery_errors = false
3136

@@ -37,6 +42,9 @@
3742
# Raise an error on page load if there are pending migrations.
3843
config.active_record.migration_error = :page_load
3944

45+
# Highlight code that triggered database queries in logs.
46+
config.active_record.verbose_query_logs = true
47+
4048
# Debug mode disables concatenation and preprocessing of assets.
4149
# This option may cause significant delays in view rendering with a large
4250
# number of complex assets.
@@ -45,7 +53,7 @@
4553
# Suppress logger output for asset requests.
4654
config.assets.quiet = true
4755

48-
# Raises error for missing translations
56+
# Raises error for missing translations.
4957
# config.action_view.raise_on_missing_translations = true
5058

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

config/environments/production.rb

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,31 @@
1414
config.consider_all_requests_local = false
1515
config.action_controller.perform_caching = true
1616

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
20+
1721
# Disable serving static files from the `/public` folder by default since
1822
# Apache or NGINX already handles this.
1923
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
2024

21-
# Compress JavaScripts and CSS.
22-
config.assets.js_compressor = :uglifier
25+
# Compress CSS using a preprocessor.
2326
# config.assets.css_compressor = :sass
2427

2528
# Do not fallback to assets pipeline if a precompiled asset is missed.
2629
config.assets.compile = false
2730

28-
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29-
3031
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3132
# config.action_controller.asset_host = 'http://assets.example.com'
3233

3334
# Specifies the header that your server uses for sending files.
3435
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
3536
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
3637

37-
# Mount Action Cable outside main process or domain
38+
# Store uploaded files on the local file system (see config/storage.yml for options).
39+
config.active_storage.service = :local
40+
41+
# Mount Action Cable outside main process or domain.
3842
# config.action_cable.mount_path = nil
3943
# config.action_cable.url = 'wss://example.com/cable'
4044
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
@@ -53,9 +57,10 @@
5357
# config.cache_store = :mem_cache_store
5458
config.cache_store = :redis_store, ENV.fetch('REDIS_URL'), { expires_in: 90.minutes }
5559

56-
# Use a real queuing backend for Active Job (and separate queues per environment)
60+
# Use a real queuing backend for Active Job (and separate queues per environment).
5761
# config.active_job.queue_adapter = :resque
58-
# config.active_job.queue_name_prefix = "rails5_#{Rails.env}"
62+
# config.active_job.queue_name_prefix = "rails_base_production"
63+
5964
config.action_mailer.perform_caching = false
6065

6166
# Ignore bad email addresses and do not raise email delivery errors.
@@ -79,9 +84,30 @@
7984
if ENV["RAILS_LOG_TO_STDOUT"].present?
8085
logger = ActiveSupport::Logger.new(STDOUT)
8186
logger.formatter = config.log_formatter
82-
config.logger = ActiveSupport::TaggedLogging.new(logger)
87+
config.logger = ActiveSupport::TaggedLogging.new(logger)
8388
end
8489

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

config/environments/test.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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!
89
config.cache_classes = true
910

1011
# Do not eager load code on boot. This avoids loading your whole application
@@ -15,18 +16,23 @@
1516
# Configure public file server for tests with Cache-Control for performance.
1617
config.public_file_server.enabled = true
1718
config.public_file_server.headers = {
18-
'Cache-Control' => 'public, max-age=3600'
19+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
1920
}
2021

2122
# Show full error reports and disable caching.
2223
config.consider_all_requests_local = true
2324
config.action_controller.perform_caching = false
25+
config.cache_store = :null_store
2426

2527
# Raise exceptions instead of rendering exception templates.
2628
config.action_dispatch.show_exceptions = false
2729

2830
# Disable request forgery protection in test environment.
2931
config.action_controller.allow_forgery_protection = false
32+
33+
# Store uploaded files on the local file system in a temporary directory.
34+
config.active_storage.service = :test
35+
3036
config.action_mailer.perform_caching = false
3137

3238
# Tell Action Mailer not to deliver emails to the real world.
@@ -37,6 +43,6 @@
3743
# Print deprecation notices to the stderr.
3844
config.active_support.deprecation = :stderr
3945

40-
# Raises error for missing translations
46+
# Raises error for missing translations.
4147
# config.action_view.raise_on_missing_translations = true
4248
end

0 commit comments

Comments
 (0)