Skip to content

Commit 9ee3fe0

Browse files
committedApr 8, 2016
upgrade to rails 5.0.0.beta3
- ran `rails rails:update` - also updated rspec-rails to 3.5.0.beta3 for rails 5 compatibility - modified puma config
1 parent 1914e1e commit 9ee3fe0

23 files changed

+270
-137
lines changed
 

‎Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ruby "2.3.0"
33

44
#
55
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
6-
gem "rails", "~>4.2"
6+
gem "rails", "5.0.0.beta3"
77

88
# Note: We're using sqllite3 for development and testing
99
gem "sqlite3", group: [:development, :test]
@@ -102,7 +102,7 @@ group :test do
102102
gem "generator_spec"
103103
gem "launchy"
104104
gem "poltergeist"
105-
gem "rspec-rails"
105+
gem "rspec-rails", "3.5.0.beta3"
106106
gem "rspec-retry"
107107
gem "selenium-webdriver", require: !["poltergeist", "poltergeist_errors_ok", "webkit"].include?(ENV["DRIVER"])
108108
end

‎Gemfile.lock

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actionmailer (4.2.6)
5-
actionpack (= 4.2.6)
6-
actionview (= 4.2.6)
7-
activejob (= 4.2.6)
4+
actioncable (5.0.0.beta3)
5+
actionpack (= 5.0.0.beta3)
6+
nio4r (~> 1.2)
7+
websocket-driver (~> 0.6.1)
8+
actionmailer (5.0.0.beta3)
9+
actionpack (= 5.0.0.beta3)
10+
actionview (= 5.0.0.beta3)
11+
activejob (= 5.0.0.beta3)
812
mail (~> 2.5, >= 2.5.4)
913
rails-dom-testing (~> 1.0, >= 1.0.5)
10-
actionpack (4.2.6)
11-
actionview (= 4.2.6)
12-
activesupport (= 4.2.6)
13-
rack (~> 1.6)
14-
rack-test (~> 0.6.2)
14+
actionpack (5.0.0.beta3)
15+
actionview (= 5.0.0.beta3)
16+
activesupport (= 5.0.0.beta3)
17+
rack (~> 2.x)
18+
rack-test (~> 0.6.3)
1519
rails-dom-testing (~> 1.0, >= 1.0.5)
1620
rails-html-sanitizer (~> 1.0, >= 1.0.2)
17-
actionview (4.2.6)
18-
activesupport (= 4.2.6)
21+
actionview (5.0.0.beta3)
22+
activesupport (= 5.0.0.beta3)
1923
builder (~> 3.1)
2024
erubis (~> 2.7.0)
2125
rails-dom-testing (~> 1.0, >= 1.0.5)
2226
rails-html-sanitizer (~> 1.0, >= 1.0.2)
23-
activejob (4.2.6)
24-
activesupport (= 4.2.6)
25-
globalid (>= 0.3.0)
26-
activemodel (4.2.6)
27-
activesupport (= 4.2.6)
28-
builder (~> 3.1)
29-
activerecord (4.2.6)
30-
activemodel (= 4.2.6)
31-
activesupport (= 4.2.6)
32-
arel (~> 6.0)
33-
activesupport (4.2.6)
27+
activejob (5.0.0.beta3)
28+
activesupport (= 5.0.0.beta3)
29+
globalid (>= 0.3.6)
30+
activemodel (5.0.0.beta3)
31+
activesupport (= 5.0.0.beta3)
32+
activerecord (5.0.0.beta3)
33+
activemodel (= 5.0.0.beta3)
34+
activesupport (= 5.0.0.beta3)
35+
arel (~> 7.0)
36+
activesupport (5.0.0.beta3)
37+
concurrent-ruby (~> 1.0)
3438
i18n (~> 0.7)
35-
json (~> 1.7, >= 1.7.7)
3639
minitest (~> 5.1)
37-
thread_safe (~> 0.3, >= 0.3.4)
3840
tzinfo (~> 1.1)
3941
addressable (2.4.0)
4042
archive-zip (0.7.0)
4143
io-like (~> 0.3.0)
42-
arel (6.0.3)
44+
arel (7.0.0)
4345
ast (2.2.0)
4446
autoprefixer-rails (6.3.6)
4547
execjs
@@ -60,8 +62,8 @@ GEM
6062
bundler-audit (0.5.0)
6163
bundler (~> 1.2)
6264
thor (~> 0.18)
63-
byebug (8.2.2)
64-
capybara (2.6.2)
65+
byebug (8.2.3)
66+
capybara (2.7.0)
6567
addressable
6668
mime-types (>= 1.16)
6769
nokogiri (>= 1.3.3)
@@ -71,8 +73,8 @@ GEM
7173
capybara-screenshot (1.0.12)
7274
capybara (>= 1.0, < 3)
7375
launchy
74-
capybara-webkit (1.9.0)
75-
capybara (>= 2.3.0, < 2.7.0)
76+
capybara-webkit (1.10.0)
77+
capybara (>= 2.3.0, < 2.8.0)
7678
json
7779
childprocess (0.5.9)
7880
ffi (~> 1.0, >= 1.0.11)
@@ -139,6 +141,7 @@ GEM
139141
mini_portile2 (2.0.0)
140142
minitest (5.8.4)
141143
multi_json (1.11.2)
144+
nio4r (1.2.1)
142145
nokogiri (1.6.7.2)
143146
mini_portile2 (~> 2.0.0.rc2)
144147
parser (2.3.0.7)
@@ -168,21 +171,23 @@ GEM
168171
pry-stack_explorer (0.4.9.2)
169172
binding_of_caller (>= 0.7)
170173
pry (>= 0.9.11)
171-
puma (3.3.0)
172-
rack (1.6.4)
174+
puma (3.4.0)
175+
rack (2.0.0.alpha)
176+
json
173177
rack-test (0.6.3)
174178
rack (>= 1.0)
175-
rails (4.2.6)
176-
actionmailer (= 4.2.6)
177-
actionpack (= 4.2.6)
178-
actionview (= 4.2.6)
179-
activejob (= 4.2.6)
180-
activemodel (= 4.2.6)
181-
activerecord (= 4.2.6)
182-
activesupport (= 4.2.6)
179+
rails (5.0.0.beta3)
180+
actioncable (= 5.0.0.beta3)
181+
actionmailer (= 5.0.0.beta3)
182+
actionpack (= 5.0.0.beta3)
183+
actionview (= 5.0.0.beta3)
184+
activejob (= 5.0.0.beta3)
185+
activemodel (= 5.0.0.beta3)
186+
activerecord (= 5.0.0.beta3)
187+
activesupport (= 5.0.0.beta3)
183188
bundler (>= 1.3.0, < 2.0)
184-
railties (= 4.2.6)
185-
sprockets-rails
189+
railties (= 5.0.0.beta3)
190+
sprockets-rails (>= 2.0.0)
186191
rails-deprecated_sanitizer (1.0.3)
187192
activesupport (>= 4.2.0.alpha)
188193
rails-dom-testing (1.0.7)
@@ -196,9 +201,10 @@ GEM
196201
rails_stdout_logging
197202
rails_serve_static_assets (0.0.5)
198203
rails_stdout_logging (0.0.5)
199-
railties (4.2.6)
200-
actionpack (= 4.2.6)
201-
activesupport (= 4.2.6)
204+
railties (5.0.0.beta3)
205+
actionpack (= 5.0.0.beta3)
206+
activesupport (= 5.0.0.beta3)
207+
method_source
202208
rake (>= 0.8.7)
203209
thor (>= 0.18.1, < 2.0)
204210
rainbow (2.1.0)
@@ -212,25 +218,25 @@ GEM
212218
rails (>= 3.2)
213219
rainbow (~> 2.1)
214220
ref (2.0.0)
215-
rspec-core (3.4.4)
216-
rspec-support (~> 3.4.0)
217-
rspec-expectations (3.4.0)
221+
rspec-core (3.5.0.beta3)
222+
rspec-support (= 3.5.0.beta3)
223+
rspec-expectations (3.5.0.beta3)
218224
diff-lcs (>= 1.2.0, < 2.0)
219-
rspec-support (~> 3.4.0)
220-
rspec-mocks (3.4.1)
225+
rspec-support (= 3.5.0.beta3)
226+
rspec-mocks (3.5.0.beta3)
221227
diff-lcs (>= 1.2.0, < 2.0)
222-
rspec-support (~> 3.4.0)
223-
rspec-rails (3.4.2)
224-
actionpack (>= 3.0, < 4.3)
225-
activesupport (>= 3.0, < 4.3)
226-
railties (>= 3.0, < 4.3)
227-
rspec-core (~> 3.4.0)
228-
rspec-expectations (~> 3.4.0)
229-
rspec-mocks (~> 3.4.0)
230-
rspec-support (~> 3.4.0)
228+
rspec-support (= 3.5.0.beta3)
229+
rspec-rails (3.5.0.beta3)
230+
actionpack (>= 3.0)
231+
activesupport (>= 3.0)
232+
railties (>= 3.0)
233+
rspec-core (= 3.5.0.beta3)
234+
rspec-expectations (= 3.5.0.beta3)
235+
rspec-mocks (= 3.5.0.beta3)
236+
rspec-support (= 3.5.0.beta3)
231237
rspec-retry (0.4.5)
232238
rspec-core
233-
rspec-support (3.4.1)
239+
rspec-support (3.5.0.beta3)
234240
rubocop (0.39.0)
235241
parser (>= 2.3.0.7, < 3.0)
236242
powerpack (~> 0.1)
@@ -343,12 +349,12 @@ DEPENDENCIES
343349
pry-rescue
344350
pry-stack_explorer
345351
puma
346-
rails (~> 4.2)
352+
rails (= 5.0.0.beta3)
347353
rails-html-sanitizer
348354
rails_12factor
349355
rainbow
350356
react_on_rails (~> 5.1.1)
351-
rspec-rails
357+
rspec-rails (= 3.5.0.beta3)
352358
rspec-retry
353359
rubocop
354360
ruby-lint

‎bin/rails

Lines changed: 0 additions & 5 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
72
APP_PATH = File.expand_path('../../config/application', __FILE__)
83
require_relative '../config/boot'
94
require 'rails/commands'

‎bin/rake

Lines changed: 0 additions & 5 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
72
require_relative '../config/boot'
83
require 'rake'
94
Rake.application.run

‎bin/setup

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
#!/usr/bin/env ruby
22
require 'pathname'
3+
require 'fileutils'
4+
include FileUtils
35

46
# path to your application root.
5-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
68

7-
Dir.chdir APP_ROOT do
9+
def system!(*args)
10+
system(*args) || abort("\n== Command #{args} failed ==")
11+
end
12+
13+
chdir APP_ROOT do
814
# This script is a starting point to setup your application.
9-
# Add necessary setup steps to this file:
15+
# Add necessary setup steps to this file.
1016

11-
puts "== Installing dependencies =="
12-
system "gem install bundler --conservative"
13-
system "bundle check || bundle install"
17+
puts '== Installing dependencies =='
18+
system! 'gem install bundler --conservative'
19+
system('bundle check') or system!('bundle install')
1420

1521
# puts "\n== Copying sample files =="
16-
# unless File.exist?("config/database.yml")
17-
# system "cp config/database.yml.sample config/database.yml"
22+
# unless File.exist?('config/database.yml')
23+
# cp 'config/database.yml.sample', 'config/database.yml'
1824
# end
1925

2026
puts "\n== Preparing database =="
21-
system "bin/rake db:setup"
27+
system! 'bin/rails db:setup'
2228

2329
puts "\n== Removing old logs and tempfiles =="
24-
system "rm -f log/*"
25-
system "rm -rf tmp/cache"
30+
system! 'bin/rails log:clear tmp:clear'
2631

2732
puts "\n== Restarting application server =="
28-
system "touch tmp/restart.txt"
33+
system! 'bin/rails restart'
2934
end

‎bin/update

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
require 'pathname'
3+
require 'fileutils'
4+
include FileUtils
5+
6+
# path to your application root.
7+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8+
9+
def system!(*args)
10+
system(*args) || abort("\n== Command #{args} failed ==")
11+
end
12+
13+
chdir APP_ROOT do
14+
# This script is a way to update your development environment automatically.
15+
# Add necessary update steps to this file.
16+
17+
puts '== Installing dependencies =='
18+
system! 'gem install bundler --conservative'
19+
system 'bundle check' or system! 'bundle install'
20+
21+
puts "\n== Updating database =="
22+
system! 'bin/rails db:migrate'
23+
24+
puts "\n== Removing old logs and tempfiles =="
25+
system! 'bin/rails log:clear tmp:clear'
26+
27+
puts "\n== Restarting application server =="
28+
system! 'bin/rails restart'
29+
end

‎config/application.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require File.expand_path("../boot", __FILE__)
1+
require File.expand_path('../boot', __FILE__)
22

3-
require "rails/all"
3+
require 'rails/all'
44

55
# Require the gems listed in Gemfile, including any gems
66
# you've limited to :test, :development, or :production.
@@ -11,16 +11,5 @@ class Application < Rails::Application
1111
# Settings in config/environments/* take precedence over those specified here.
1212
# Application configuration should go into files in config/initializers
1313
# -- all .rb files in that directory are automatically loaded.
14-
15-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17-
# config.time_zone = "Central Time (US & Canada)"
18-
19-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20-
# config.i18n.load_path += Dir[Rails.root.join("my", "locales", "*.{rb,yml}").to_s]
21-
# config.i18n.default_locale = :de
22-
23-
# For not swallow errors in after_commit/after_rollback callbacks.
24-
config.active_record.raise_in_transactional_callbacks = true
2514
end
2615
end

‎config/boot.rb

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

3-
require "bundler/setup" # Set up gems listed in the Gemfile.
3+
require 'bundler/setup' # Set up gems listed in the Gemfile.

‎config/cable.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Action Cable uses Redis by default to administer connections, channels, and sending/receiving messages over the WebSocket.
2+
production:
3+
adapter: redis
4+
url: redis://localhost:6379/1
5+
6+
development:
7+
adapter: async
8+
9+
test:
10+
adapter: async

‎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 File.expand_path("../application", __FILE__)
2+
require File.expand_path('../application', __FILE__)
33

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

‎config/environments/development.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,26 @@
99
# Do not eager load code on boot.
1010
config.eager_load = false
1111

12-
# Show full error reports and disable caching.
12+
# Show full error reports.
1313
config.consider_all_requests_local = true
14-
config.action_controller.perform_caching = false
14+
15+
# Enable/disable caching. By default caching is disabled.
16+
if Rails.root.join('tmp/caching-dev.txt').exist?
17+
config.action_controller.perform_caching = true
18+
19+
config.action_mailer.perform_caching = false
20+
21+
config.cache_store = :memory_store
22+
config.public_file_server.headers = {
23+
'Cache-Control' => 'public, max-age=172800'
24+
}
25+
else
26+
config.action_controller.perform_caching = false
27+
28+
config.action_mailer.perform_caching = false
29+
30+
config.cache_store = :null_store
31+
end
1532

1633
# Don't care if the mailer can't send.
1734
config.action_mailer.raise_delivery_errors = false
@@ -38,4 +55,8 @@
3855

3956
# Raises error for missing translations
4057
# config.action_view.raise_on_missing_translations = true
58+
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
4162
end

‎config/environments/production.rb

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
config.eager_load = true
1212

1313
# Full error reports are disabled and caching is turned on.
14-
config.consider_all_requests_local = false
14+
config.consider_all_requests_local = false
1515
config.action_controller.perform_caching = true
1616

17-
# Enable Rack::Cache to put a simple HTTP cache in front of your application
18-
# Add `rack-cache` to your Gemfile before enabling this.
19-
# For large-scale production use, consider using a caching reverse proxy like NGINX, varnish or squid.
20-
# config.action_dispatch.rack_cache = true
21-
22-
# Disable Rails's static asset server (Apache or NGINX will already do this).
23-
config.serve_static_files = false
17+
# Disable serving static files from the `/public` folder by default since
18+
# Apache or NGINX already handles this.
19+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
2420

2521
# Compress JavaScripts and CSS.
2622
config.assets.js_compressor = :uglifier
@@ -35,27 +31,42 @@
3531

3632
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
3733

34+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
35+
# config.action_controller.asset_host = 'http://assets.example.com'
36+
3837
# Specifies the header that your server uses for sending files.
39-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
40-
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
38+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
39+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
40+
41+
# Action Cable endpoint configuration
42+
# config.action_cable.url = 'wss://example.com/cable'
43+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
4144

4245
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
4346
# config.force_ssl = true
4447

45-
# Set to :info to decrease the log volume.
48+
# Use the lowest log level to ensure availability of diagnostic information
49+
# when problems arise.
4650
config.log_level = :debug
4751

4852
# Prepend all log lines with the following tags.
49-
# config.log_tags = [ :subdomain, :uuid ]
53+
config.log_tags = [ :request_id ]
5054

5155
# Use a different logger for distributed setups.
52-
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56+
# require 'syslog/logger'
57+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
58+
59+
if ENV["RAILS_LOG_TO_STDOUT"].present?
60+
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
61+
end
5362

5463
# Use a different cache store in production.
5564
# config.cache_store = :mem_cache_store
5665

57-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
58-
# config.action_controller.asset_host = "http://assets.example.com"
66+
# Use a real queuing backend for Active Job (and separate queues per environment)
67+
# config.active_job.queue_adapter = :resque
68+
# config.active_job.queue_name_prefix = "rails_react_tutorial_#{Rails.env}"
69+
config.action_mailer.perform_caching = false
5970

6071
# Ignore bad email addresses and do not raise email delivery errors.
6172
# Set this to true and configure the email server for immediate delivery to raise delivery errors.

‎config/environments/test.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
# preloads Rails for running tests, you may have to set it to true.
1313
config.eager_load = false
1414

15-
# Configure static asset server for tests with Cache-Control for performance.
16-
config.serve_static_files = true
17-
config.static_cache_control = "public, max-age=3600"
15+
# Configure public file server for tests with Cache-Control for performance.
16+
config.public_file_server.enabled = true
17+
config.public_file_server.headers = {
18+
'Cache-Control' => 'public, max-age=3600'
19+
}
1820

1921
# Show full error reports and disable caching.
2022
config.consider_all_requests_local = true
@@ -25,6 +27,7 @@
2527

2628
# Disable request forgery protection in test environment.
2729
config.action_controller.allow_forgery_protection = false
30+
config.action_mailer.perform_caching = false
2831

2932
# Tell Action Mailer not to deliver emails to the real world.
3033
# The :test delivery method accumulates sent emails in the
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# ApplicationController.renderer.defaults.merge!(
4+
# http_host: 'example.org',
5+
# https: false
6+
# )

‎config/initializers/assets.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Be sure to restart your server when you modify this file.
22

33
# Version of your assets, change this if you want to expire all your assets.
4-
Rails.application.config.assets.version = "1.0"
4+
Rails.application.config.assets.version = '1.0'
55

66
# Add folder with webpack generated assets to assets.paths
77
Rails.application.config.assets.paths << Rails.root.join("app", "assets", "webpack")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Be sure to restart your server when you modify this file.
22

3+
# Specify a serializer for the signed and encrypted cookie jars.
4+
# Valid options are :json, :marshal, and :hybrid.
35
Rails.application.config.action_dispatch.cookies_serializer = :json

‎config/initializers/cors.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# Avoid CORS issues when API is called from the frontend app.
4+
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
5+
6+
# Read more: https://github.com/cyu/rack-cors
7+
8+
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
9+
# allow do
10+
# origins 'example.com'
11+
#
12+
# resource '*',
13+
# headers: :any,
14+
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
15+
# end
16+
# end

‎config/initializers/inflections.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# are locale specific, and you may define rules for as many different
55
# locales as you wish. All of these examples are active by default:
66
# ActiveSupport::Inflector.inflections(:en) do |inflect|
7-
# inflect.plural /^(ox)$/i, "\1en"
8-
# inflect.singular /^(ox)en/i, "\1"
9-
# inflect.irregular "person", "people"
7+
# inflect.plural /^(ox)$/i, '\1en'
8+
# inflect.singular /^(ox)en/i, '\1'
9+
# inflect.irregular 'person', 'people'
1010
# inflect.uncountable %w( fish sheep )
1111
# end
1212

1313
# These inflection rules are supported but not enabled by default:
1414
# ActiveSupport::Inflector.inflections(:en) do |inflect|
15-
# inflect.acronym "RESTful"
15+
# inflect.acronym 'RESTful'
1616
# end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# Enable per-form CSRF tokens.
4+
Rails.application.config.action_controller.per_form_csrf_tokens = true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# Enable origin-checking CSRF mitigation.
4+
Rails.application.config.action_controller.forgery_protection_origin_check = true

‎config/initializers/wrap_parameters.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
77
ActiveSupport.on_load(:action_controller) do
8-
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
8+
wrap_parameters format: [:json]
99
end
1010

1111
# To enable root element in JSON for ActiveRecord objects.
1212
# ActiveSupport.on_load(:active_record) do
13-
# self.include_root_in_json = true
13+
# self.include_root_in_json = true
1414
# end

‎config/puma.rb

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
1-
workers Integer(ENV["WEB_CONCURRENCY"] || 2)
2-
threads_count = Integer(ENV["MAX_THREADS"] || 5)
1+
# Puma can serve each request in a thread from an internal thread pool.
2+
# The `threads` method setting takes two numbers a minimum and maximum.
3+
# Any libraries that use thread pools should be configured to match
4+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
5+
# and maximum, this matches the default thread size of Active Record.
6+
#
7+
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
38
threads threads_count, threads_count
49

5-
preload_app!
10+
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11+
#
12+
port ENV.fetch("PORT") { 3000 }
13+
14+
# Specifies the `environment` that Puma will run in.
15+
#
16+
environment ENV.fetch("RAILS_ENV") { "development" }
617

7-
rackup DefaultRackup
8-
port ENV["PORT"] || 3000
9-
environment ENV["RACK_ENV"] || "development"
18+
# Specifies the number of `workers` to boot in clustered mode.
19+
# Workers are forked webserver processes. If using threads and workers together
20+
# the concurrency of the application would be max `threads` * `workers`.
21+
# Workers do not work on JRuby or Windows (both of which do not support
22+
# processes).
23+
#
24+
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
1025

26+
# Use the `preload_app!` method when specifying a `workers` number.
27+
# This directive tells Puma to first boot the application and load code
28+
# before forking the application. This takes advantage of Copy On Write
29+
# process behavior so workers use less memory. If you use this option
30+
# you need to make sure to reconnect any threads in the `on_worker_boot`
31+
# block.
32+
#
33+
preload_app!
34+
35+
# The code in the `on_worker_boot` will be called if you are using
36+
# clustered mode by specifying a number of `workers`. After each worker
37+
# process is booted this block will be run, if you are using `preload_app!`
38+
# option you will want to use this block to reconnect to any threads
39+
# or connections that may have been created at application boot, Ruby
40+
# cannot share connections between processes.
41+
#
1142
on_worker_boot do
12-
# Worker specific setup for Rails 4.1+
13-
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
14-
ActiveRecord::Base.establish_connection
43+
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
1544
end
45+
46+
# Allow puma to be restarted by `rails restart` command.
47+
plugin :tmp_restart

‎config/routes.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
Rails.application.routes.draw do
2+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3+
4+
# Serve websocket cable requests in-process
5+
# mount ActionCable.server => '/cable'
6+
27
root "pages#index"
38

49
get "simple", to: "pages#simple"

0 commit comments

Comments
 (0)
Please sign in to comment.