Upgrade to Rails 6.0 and apply new framework defaults

This commit is contained in:
Sebastian Serth
2021-05-10 22:04:49 +02:00
parent 3c4ff307af
commit 8378070bc2
25 changed files with 232 additions and 171 deletions

View File

@@ -1,3 +1,7 @@
# frozen_string_literal: true
require 'code_ocean/config'
CodeOcean::Config.new(:action_mailer).read.each do |key, value|
CodeOcean::Application.config.action_mailer.send(:"#{key}=", value.respond_to?(:symbolize_keys) ? value.symbolize_keys : value)
end

View File

@@ -1,20 +1,19 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
Rails.application.config.tap do |config|
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Add additional assets to the asset load 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')
# Add additional assets to the asset load path.
# config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# config.assets.precompile += %w( admin.js admin.css )
end
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += %w( markdown-buttons.png )
# Disable concurrent asset compilation to prevent segfault # https://github.com/sass/sassc-ruby/issues/197
# Reproduce: `rake assets:clobber`, `rake assets:precompile`. If the command succeeds, it worked

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
@@ -11,10 +13,7 @@
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
#
# # You need to allow webpack-dev-server host as allowed origin for connect-src.
# # This can be done in Rails 5.2+ for development environment in the CSP initializer
# # config/initializers/content_security_policy.rb with a snippet like this:
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
# # Specify URI for violation reports
@@ -24,6 +23,9 @@
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only

View File

@@ -1,8 +1,5 @@
# frozen_string_literal: true
require 'docker_client'
DockerClient.initialize_environment unless Rails.env.test? && `which docker`.blank?
return if Rake.application.top_level_tasks.to_s.include?('db:')
if ApplicationRecord.connection.tables.present? &&
DockerContainerPool.config[:active]
# no op
end

View File

@@ -1 +1,5 @@
Docker::Container.send(:include, DockerContainerMixin)
# frozen_string_literal: true
require 'docker_container_mixin'
Docker::Container.include DockerContainerMixin

View File

@@ -1,9 +1,13 @@
# frozen_string_literal: true
require 'code_ocean/config'
return unless CodeOcean::Config.new(:code_ocean).read[:prometheus_exporter][:enabled] && !defined?(::Rails::Console)
return if %w[db: assets:].any? { |task| Rake.application.top_level_tasks.to_s.include?(task) }
# Add metric callbacks to all models
ApplicationRecord.include Prometheus::Record
ActiveSupport.on_load :active_record do
include Prometheus::Record
end
# Initialization is performed in config/application.rb

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
RailsAdmin.config do |config|
### Popular gems integration