Rails 5.1

This commit is contained in:
Patrick Gansterer 2020-07-31 23:47:14 +02:00
parent 74531f90c7
commit 4642eb6c54
10 changed files with 112 additions and 59 deletions

View file

@ -1,7 +1,7 @@
# A sample Gemfile # A sample Gemfile
source "https://rubygems.org" source "https://rubygems.org"
gem "rails", '< 5.1' gem "rails", '< 5.2'
gem 'sass-rails' gem 'sass-rails'
gem 'less-rails' gem 'less-rails'
@ -75,6 +75,7 @@ group :development do
gem 'sqlite3', '~> 1.3.6' gem 'sqlite3', '~> 1.3.6'
gem 'mailcatcher' gem 'mailcatcher'
gem 'web-console' gem 'web-console'
gem 'listen'
# Better error output # Better error output
gem 'better_errors' gem 'better_errors'

View file

@ -65,27 +65,27 @@ PATH
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (5.0.7.2) actioncable (5.1.7)
actionpack (= 5.0.7.2) actionpack (= 5.1.7)
nio4r (>= 1.2, < 3.0) nio4r (~> 2.0)
websocket-driver (~> 0.6.1) websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2) actionmailer (5.1.7)
actionpack (= 5.0.7.2) actionpack (= 5.1.7)
actionview (= 5.0.7.2) actionview (= 5.1.7)
activejob (= 5.0.7.2) activejob (= 5.1.7)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (5.0.7.2) actionpack (5.1.7)
actionview (= 5.0.7.2) actionview (= 5.1.7)
activesupport (= 5.0.7.2) activesupport (= 5.1.7)
rack (~> 2.0) rack (~> 2.0)
rack-test (~> 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.7.2) actionview (5.1.7)
activesupport (= 5.0.7.2) activesupport (= 5.1.7)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.10.10) active_model_serializers (0.10.10)
@ -93,16 +93,16 @@ GEM
activemodel (>= 4.1, < 6.1) activemodel (>= 4.1, < 6.1)
case_transform (>= 0.2) case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3) jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (5.0.7.2) activejob (5.1.7)
activesupport (= 5.0.7.2) activesupport (= 5.1.7)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (5.0.7.2) activemodel (5.1.7)
activesupport (= 5.0.7.2) activesupport (= 5.1.7)
activerecord (5.0.7.2) activerecord (5.1.7)
activemodel (= 5.0.7.2) activemodel (= 5.1.7)
activesupport (= 5.0.7.2) activesupport (= 5.1.7)
arel (~> 7.0) arel (~> 8.0)
activesupport (5.0.7.2) activesupport (5.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
@ -121,7 +121,7 @@ GEM
apparition (0.6.0) apparition (0.6.0)
capybara (~> 3.13, < 4) capybara (~> 3.13, < 4)
websocket-driver (>= 0.6.5) websocket-driver (>= 0.6.5)
arel (7.1.4) arel (8.0.0)
attribute_normalizer (1.2.0) attribute_normalizer (1.2.0)
base32 (0.3.4) base32 (0.3.4)
better_errors (2.7.1) better_errors (2.7.1)
@ -208,12 +208,12 @@ GEM
haml (5.1.2) haml (5.1.2)
temple (>= 0.8.0) temple (>= 0.8.0)
tilt tilt
haml-rails (1.0.0) haml-rails (2.0.1)
actionpack (>= 4.0.1) actionpack (>= 5.1)
activesupport (>= 4.0.1) activesupport (>= 5.1)
haml (>= 4.0.6, < 6.0) haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1) html2haml (>= 1.0.1)
railties (>= 4.0.1) railties (>= 5.1)
has_scope (0.7.2) has_scope (0.7.2)
actionpack (>= 4.1) actionpack (>= 4.1)
activesupport (>= 4.1) activesupport (>= 4.1)
@ -266,6 +266,9 @@ GEM
less (~> 2.6.0) less (~> 2.6.0)
sprockets (~> 3.0) sprockets (~> 3.0)
libv8 (3.16.14.19) libv8 (3.16.14.19)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.7.0) loofah (2.7.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
@ -328,19 +331,19 @@ GEM
rack (>= 2.0.0) rack (>= 2.0.0)
rack-protection (2.1.0) rack-protection (2.1.0)
rack rack
rack-test (0.6.3) rack-test (1.1.0)
rack (>= 1.0) rack (>= 1.0, < 3)
rails (5.0.7.2) rails (5.1.7)
actioncable (= 5.0.7.2) actioncable (= 5.1.7)
actionmailer (= 5.0.7.2) actionmailer (= 5.1.7)
actionpack (= 5.0.7.2) actionpack (= 5.1.7)
actionview (= 5.0.7.2) actionview (= 5.1.7)
activejob (= 5.0.7.2) activejob (= 5.1.7)
activemodel (= 5.0.7.2) activemodel (= 5.1.7)
activerecord (= 5.0.7.2) activerecord (= 5.1.7)
activesupport (= 5.0.7.2) activesupport (= 5.1.7)
bundler (>= 1.3.0) bundler (>= 1.3.0)
railties (= 5.0.7.2) railties (= 5.1.7)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-assets-listjs (0.2.0.beta.4) rails-assets-listjs (0.2.0.beta.4)
railties (>= 3.1) railties (>= 3.1)
@ -356,9 +359,9 @@ GEM
rails (>= 4.2.0) rails (>= 4.2.0)
rails_tokeninput (1.7.0) rails_tokeninput (1.7.0)
railties (>= 3.1.0) railties (>= 3.1.0)
railties (5.0.7.2) railties (5.1.7)
actionpack (= 5.0.7.2) actionpack (= 5.1.7)
activesupport (= 5.0.7.2) activesupport (= 5.1.7)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
@ -370,6 +373,9 @@ GEM
activesupport (>= 5.0) activesupport (>= 5.0)
i18n i18n
polyamorous (= 2.3.0) polyamorous (= 2.3.0)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
recurring_select (2.1.0) recurring_select (2.1.0)
coffee-rails (>= 3.1) coffee-rails (>= 3.1)
ice_cube (>= 0.11) ice_cube (>= 0.11)
@ -567,6 +573,7 @@ DEPENDENCIES
jquery-rails jquery-rails
kaminari kaminari
less-rails less-rails
listen
localize_input! localize_input!
mailcatcher mailcatcher
meta_request meta_request
@ -579,7 +586,7 @@ DEPENDENCIES
pry-stack_explorer pry-stack_explorer
puma puma
rack-cors rack-cors
rails (< 5.1) rails (< 5.2)
rails-assets-listjs (= 0.2.0.beta.4) rails-assets-listjs (= 0.2.0.beta.4)
rails-i18n rails-i18n
rails-settings-cached (= 0.4.3) rails-settings-cached (= 0.4.3)

View file

@ -18,6 +18,10 @@ chdir APP_ROOT do
system! 'gem install bundler --conservative' system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install') system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml') # unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml' # cp 'config/database.yml.sample', 'config/database.yml'

11
bin/yarn Executable file
View file

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

View file

@ -22,7 +22,7 @@ Rails.application.configure do
config.cache_store = :memory_store config.cache_store = :memory_store
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800' 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
} }
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
@ -65,7 +65,7 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code, # Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem. # routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Run resque tasks as part of the main app (not recommended for production) # Run resque tasks as part of the main app (not recommended for production)
Resque.inline = true unless ENV['REDIS_URL'] Resque.inline = true unless ENV['REDIS_URL']

View file

@ -18,6 +18,11 @@ Rails.application.configure do
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
# `config/secrets.yml.key`.
config.read_encrypted_secrets = true
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

View file

@ -19,7 +19,7 @@ Rails.application.configure do
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600' 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
} }
# Show full error reports and disable caching. # Show full error reports and disable caching.

View file

@ -3,9 +3,12 @@
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path # Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in the app/assets
# Rails.application.config.assets.precompile += %w( search.js ) # folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

View file

@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.1 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Make `form_with` generate non-remote forms.
Rails.application.config.action_view.form_with_generates_remote_forms = false
# Unknown asset fallback will return the path passed in when the given
# asset is not present in the asset pipeline.
# Rails.application.config.assets.unknown_asset_fallback = false

View file

@ -1,13 +1,13 @@
# Puma can serve each request in a thread from an internal thread pool. # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum. # The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match # Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum # the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record. # and maximum; this matches the default thread size of Active Record.
# #
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 1 }.to_i threads_count = ENV.fetch("RAILS_MAX_THREADS") { 1 }
threads threads_count, threads_count threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000. # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
# #
port ENV.fetch("PORT") { 3000 } port ENV.fetch("PORT") { 3000 }
@ -32,11 +32,19 @@ workers ENV.fetch("WEB_CONCURRENCY") { 8 }
# #
preload_app! preload_app!
# If you are preloading your application and using Active Record, it's
# recommended that you close any connections to the database before workers
# are forked to prevent connection leakage.
#
before_fork do
ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
end
# The code in the `on_worker_boot` will be called if you are using # The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker # clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!` # process is booted, this block will be run. If you are using the `preload_app!`
# option you will want to use this block to reconnect to any threads # option, you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby # or connections that may have been created at application boot, as Ruby
# cannot share connections between processes. # cannot share connections between processes.
# #
on_worker_boot do on_worker_boot do