Skip to content

Commit b4f3971

Browse files
committed
rails 5.1 changes
1 parent 5acfe02 commit b4f3971

22 files changed

+101
-59
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
/log/*
1616
!/log/.keep
1717
/tmp
18+
/node_modules
19+
/yarn-error.log
1820
.byebug_history
1921

2022
# OS X Files

Gemfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ruby '2.4.1'
1010
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
1111
gem 'rails', '~> 5.1.5'
1212
# Use postgresql as the database for Active Record
13-
gem 'pg', '~> 0.18'
13+
gem 'pg', '~> 0.21'
1414
# Use Puma as the app server
1515
gem 'puma', '~> 3.8.0'
1616
gem 'rack-timeout'
@@ -39,7 +39,7 @@ gem 'turbolinks', '~> 5'
3939
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
4040
gem 'jbuilder'
4141
# Use Redis adapter to run Action Cable in production
42-
# gem 'redis', '~> 3.0'
42+
# gem 'redis', '~> 4.0'
4343
# Use ActiveModel has_secure_password
4444
gem 'bcrypt', '~> 3.1.7'
4545

@@ -66,7 +66,7 @@ group :development, :test do
6666

6767
gem 'rspec-rails'
6868
gem 'factory_girl_rails'
69-
gem 'capybara'
69+
gem 'capybara', '~> 2.13'
7070
gem 'launchy'
7171
gem 'selenium-webdriver'
7272
gem 'database_cleaner'
@@ -81,7 +81,7 @@ end
8181
group :development do
8282
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
8383
gem 'web-console', '>= 3.3.0'
84-
gem 'listen', '~> 3.0.5'
84+
gem 'listen', '>= 3.0.5', '< 3.2'
8585
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
8686
gem 'spring'
8787
gem 'spring-watcher-listen', '~> 2.0.0'

Gemfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,18 @@ DEPENDENCIES
302302
bootstrap3-datetimepicker-rails (~> 4.17.42)
303303
bootstrap_form (~> 2.4)
304304
byebug
305-
capybara
305+
capybara (~> 2.13)
306306
coffee-rails (~> 4.2)
307307
database_cleaner
308308
factory_girl_rails
309309
faker
310310
jbuilder
311311
jquery-rails
312312
launchy
313-
listen (~> 3.0.5)
313+
listen (>= 3.0.5, < 3.2)
314314
momentjs-rails (>= 2.9.0)
315315
nokogiri (~> 1.8.0)
316-
pg (~> 0.18)
316+
pg (~> 0.21)
317317
pgbackups-archive
318318
puma (~> 3.8.0)
319319
pundit

app/assets/javascripts/application.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//
1313
//= require jquery
1414
//= require jquery_ujs
15+
//= require rails-ujs
1516
//= require turbolinks
1617
//= require bootstrap-sprockets
1718
//= require moment

bin/setup

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ chdir APP_ROOT do
1818
system! 'gem install bundler --conservative'
1919
system('bundle check') || system!('bundle install')
2020

21+
# Install JavaScript dependencies if using Yarn
22+
# system('bin/yarn')
23+
2124
# puts "\n== Copying sample files =="
2225
# unless File.exist?('config/database.yml')
2326
# cp 'config/database.yml.sample', 'config/database.yml'

bin/yarn

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env ruby
2+
VENDOR_PATH = File.expand_path('..', __dir__)
3+
Dir.chdir(VENDOR_PATH) do
4+
begin
5+
exec "yarnpkg #{ARGV.join(" ")}"
6+
rescue Errno::ENOENT
7+
$stderr.puts "Yarn executable was not detected in the system."
8+
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9+
exit 1
10+
end
11+
end

config/application.rb

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
module WrapManager
1010
class Application < Rails::Application
11+
# Initialize configuration defaults for originally generated Rails version.
12+
config.load_defaults 5.1
13+
1114
# Settings in config/environments/* take precedence over those specified here.
1215
# Application configuration should go into files in config/initializers
1316
# -- all .rb files in that directory are automatically loaded.

config/cable.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ test:
77
production:
88
adapter: redis
99
url: redis://localhost:6379/1
10+
channel_prefix: railsdiff_production

config/environments/development.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
config.cache_store = :memory_store
2020
config.public_file_server.headers = {
21-
'Cache-Control' => 'public, max-age=172800'
21+
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
2222
}
2323
else
2424
config.action_controller.perform_caching = false

config/environments/production.rb

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
config.consider_all_requests_local = false
1515
config.action_controller.perform_caching = true
1616

17+
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
18+
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
19+
# `config/secrets.yml.key`.
20+
config.read_encrypted_secrets = true
21+
1722
# Disable serving static files from the `/public` folder by default since
1823
# Apache or NGINX already handles this.
1924
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

config/environments/test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Configure public file server for tests with Cache-Control for performance.
1616
config.public_file_server.enabled = true
1717
config.public_file_server.headers = {
18-
'Cache-Control' => 'public, max-age=3600'
18+
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
1919
}
2020

2121
# Show full error reports and disable caching.

config/initializers/application_controller_renderer.rb

+6
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
# http_host: 'example.org',
55
# https: false
66
# )
7+
# ActiveSupport::Reloader.to_prepare do
8+
# ApplicationController.renderer.defaults.merge!(
9+
# http_host: 'example.org',
10+
# https: false
11+
# )
12+
# end

config/initializers/assets.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
# Add additional assets to the asset load path
77
# Rails.application.config.assets.paths << Emoji.images_path
8+
# Add Yarn node_modules folder to the asset load path.
9+
Rails.application.config.assets.paths << Rails.root.join('node_modules')
810

911
# Precompile additional assets.
10-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11-
# Rails.application.config.assets.precompile += %w( search.js )
12+
# application.js, application.css, and all non-JS/CSS in the app/assets
13+
# folder are already added.
14+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

config/initializers/new_framework_defaults.rb

-24
This file was deleted.

config/initializers/session_store.rb

-3
This file was deleted.

config/locales/en.yml

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
# I18n.locale = :es
1616
#
1717
# This would use the information in config/locales/es.yml.
18+
# The following keys must be escaped otherwise they will not be retrieved by
19+
# the default I18n backend:
20+
#
21+
# true, false, on, off, yes, no
22+
#
23+
# Instead, surround them with single quotes.
24+
#
25+
# en:
26+
# 'true': 'foo'
27+
#
1828
#
1929
# To learn more, please read the Rails Internationalization guide
2030
# available at http://guides.rubyonrails.org/i18n.html.

config/puma.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# the maximum value specified for Puma. Default is set to 5 threads for minimum
55
# and maximum, this matches the default thread size of Active Record.
66
#
7-
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
7+
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
88
threads threads_count, threads_count
99

1010
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
@@ -32,6 +32,14 @@
3232
#
3333
preload_app!
3434

35+
# If you are preloading your application and using Active Record, it's
36+
# recommended that you close any connections to the database before workers
37+
# are forked to prevent connection leakage.
38+
#
39+
before_fork do
40+
ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
41+
end
42+
3543
# The code in the `on_worker_boot` will be called if you are using
3644
# clustered mode by specifying a number of `workers`. After each worker
3745
# process is booted this block will be run, if you are using `preload_app!`

config/secrets.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@
1010
# Make sure the secrets in this file are kept private
1111
# if you're sharing your code publicly.
1212

13+
# Shared secrets are available across all environments.
14+
15+
# shared:
16+
# api_key: a1B2c3D4e5F6
17+
18+
# Environmental secrets are only available for that specific environment.
19+
20+
1321
development:
1422
secret_key_base: ca598f663c374d31f0acbe99083ff9a3c4081a0c43d1dcb937e6877ef1bdfde2fa06d07e4e17d452afd245c7de8dd7b91f580206ed25eb1c0fa22703ac68fac3
1523

1624
test:
1725
secret_key_base: 84a0b916dcfa04a1ce4da13f765ecc2701dd4467c6e7eb0195958a56b66783a8376e002d54f08ef74adcf23e42451e86c3e75113544042c764f351c9d022f5e6
1826

19-
# Do not keep production secrets in the repository,
20-
# instead read values from the environment.
27+
# Do not keep production secrets in the unencrypted secrets file.
28+
# Instead, either read values from the environment.
29+
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
30+
# and move the `production:` environment over there.
31+
2132
production:
2233
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "railsdiff",
3+
"private": true,
4+
"dependencies": {}
5+
}

public/404.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
<title>The page you were looking for doesn't exist (404)</title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
66
<style>
7-
body {
7+
.rails-default-error-page {
88
background-color: #EFEFEF;
99
color: #2E2F30;
1010
text-align: center;
1111
font-family: arial, sans-serif;
1212
margin: 0;
1313
}
1414

15-
div.dialog {
15+
.rails-default-error-page div.dialog {
1616
width: 95%;
1717
max-width: 33em;
1818
margin: 4em auto 0;
1919
}
2020

21-
div.dialog > div {
21+
.rails-default-error-page div.dialog > div {
2222
border: 1px solid #CCC;
2323
border-right-color: #999;
2424
border-left-color: #999;
@@ -31,13 +31,13 @@
3131
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
3232
}
3333

34-
h1 {
34+
.rails-default-error-page h1 {
3535
font-size: 100%;
3636
color: #730E15;
3737
line-height: 1.5em;
3838
}
3939

40-
div.dialog > p {
40+
.rails-default-error-page div.dialog > p {
4141
margin: 0 0 1em;
4242
padding: 1em;
4343
background-color: #F7F7F7;
@@ -54,7 +54,7 @@
5454
</style>
5555
</head>
5656

57-
<body>
57+
<body class="rails-default-error-page">
5858
<!-- This file lives in public/404.html -->
5959
<div class="dialog">
6060
<div>

public/422.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
<title>The change you wanted was rejected (422)</title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
66
<style>
7-
body {
7+
.rails-default-error-page {
88
background-color: #EFEFEF;
99
color: #2E2F30;
1010
text-align: center;
1111
font-family: arial, sans-serif;
1212
margin: 0;
1313
}
1414

15-
div.dialog {
15+
.rails-default-error-page div.dialog {
1616
width: 95%;
1717
max-width: 33em;
1818
margin: 4em auto 0;
1919
}
2020

21-
div.dialog > div {
21+
.rails-default-error-page div.dialog > div {
2222
border: 1px solid #CCC;
2323
border-right-color: #999;
2424
border-left-color: #999;
@@ -31,13 +31,13 @@
3131
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
3232
}
3333

34-
h1 {
34+
.rails-default-error-page h1 {
3535
font-size: 100%;
3636
color: #730E15;
3737
line-height: 1.5em;
3838
}
3939

40-
div.dialog > p {
40+
.rails-default-error-page div.dialog > p {
4141
margin: 0 0 1em;
4242
padding: 1em;
4343
background-color: #F7F7F7;
@@ -54,7 +54,7 @@
5454
</style>
5555
</head>
5656

57-
<body>
57+
<body class="rails-default-error-page">
5858
<!-- This file lives in public/422.html -->
5959
<div class="dialog">
6060
<div>

0 commit comments

Comments
 (0)