-
Notifications
You must be signed in to change notification settings - Fork 2
Upgrading projects to rails 6
dedek edited this page May 20, 2020
·
10 revisions
Update ruby to 2.6.6 and install bundle.
rvm install 2.6.6
gem install bundler
Update Gemfile
# Gemfile
gem 'rails', '~> 6.0.2.2'
gem 'pg', '~> 1.2.3'
Update test environment
# config/environments/test.rb
config.cache_classes = false
Remove all references to autoloaded paths from initializers! Do not i.e. set values based on Folio::Site.instance
, as it breaks zeitwerk autoloading.
Rename decorators to overrides and add setup to application.rb
to work with zeitwerk.
cd root_of_the_project || exit 1
mv app/decorators app/overrides
for f in app/overrides/**/*_decorator.rb; do newname="${f/_decorator.rb/_override.rb}"; mv $f $newname; done
# config/application.rb
#...
module Dummy
class Application < Rails::Application
#..
config.load_defaults 6.0
#...
Rails.autoloaders.main.ignore("#{::Folio::Engine.root}/app/lib/folio/console/simple_form_components")
Rails.autoloaders.main.ignore("#{::Folio::Engine.root}/app/lib/folio/console/simple_form_inputs")
overrides = [
Folio::Engine.root.join('app/overrides').to_s,
Rails.root.join('app/overrides').to_s,
]
overrides.each { |override| Rails.autoloaders.main.ignore(override) }
config.to_prepare do
overrides.each do |override|
Dir.glob("#{override}/**/*_override.rb").each do |file|
load file
end
end
Dir.glob("#{::Folio::Engine.root}/app/lib/folio/console/simple_form*/**.rb").each do |sf|
load sf
end
end
end
end
Change rvm_ruby_version
in deploy.rb
# config/deploy.rb
set :rvm_ruby_version, '2.6.6'
Change TargetRubyVersion
in rubocop config
# .rubocop.yml
AllCops:
TargetRubyVersion: 2.6.6