2.2.2+
2.3.1ApplicationRecord
app/models/application_record.rb with the following code:class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
before callbacks would return false in ActiveRecord and ActiveModel and thereby halting the entire execution chain.
throw(:abort)config/application.rb: ActiveSupport.halt_callback_chains_on_return_false = falseActiveJob now inherits from ApplicationJob
app/jobs/application_job.rb add the following codeclass ApplicationJob < ActiveJob::Base
end
assigns and assert_template in controller tests add gem 'rails-controller-testing' to gemfileActionDispatch::Http::UploadFile replace with Rack::Test::UploadedFileRails.application.config.enable_dependency_loading = trueActiveModel::Serializers::Xml has been extracted into a gem: gem 'activemodel-serializers-xml'mysql has been removed, use mysql2rails instead of rake for running tasks and testsparams will now return an object instead of a hash.
params.permit then no changes are needed.params.permit([:proceed_to, :return_to]).to_hprotect_from_forgery defaults to prepend: falseRAW. Always specify the extension of your file to be parsed by an appropriate template handlercontent_tag_for and div_for have been removed in favor of just using content_tag, to continue using the older view helper methods
add the gem gem 'record_tag_helper', '~> 1.0' to gemfileprotected_attributes gem is no longer supported in Rails 5!activerecord-deprecated_finders gem is no longer supported in Rails 5!# config/environments/test.rb
Rails.application.configure do
config.active_support.test_order = :sorted
end
ActionController::Live became a concern!
ActionController::Live is included in another module that is included in your controller, then you should extend the module with ActiveSupport::Concernbelongs_to will now trigger a validation error by default if there is no association present
optional: trueconfig.active_record.belongs_to_required_by_default = trueconfig.action_controller.per_form_csrf_tokens = trueOrigin header should be checked against
the site's origin: config.action_controller.forgery_protection_origin_check = truemailers, you can change it with this configuration: config.action_mailer.deliver_later_queue_name = :new_queue_nameconfig.action_mailer.perform_caching = trueconfig.active_record.dump_schemas = :allconfig.ssl_options = { hsts: { subdomains: true } }ActiveSupport.to_time_preserves_timezone = falseString, but pass a Hash instead, which will be converted to and from a JSON string automaticallyHashWithIndifferentAccess class, move to using ActiveSupport::HashWithIndifferentAccessconfig/secrets.yml all keys are now loaded as symbols, using strings should be changed!app:update sets it up in boot.rb, use it then add to gemfileboot.rbRails.application.config.action_dispatch.use_authenticated_cookie_encryption: falsegem 'rails', ~> '6.0' for examplebundle update railsrails app:updatenew_framework_defaults.rb file to uncomment any
modified settingsgem 'webpacker'
bin/rails webpacker:installforce_ssl in controllers has been deprecated and will be removed in 6.1Rails.application.config.action_dispatch.use_cookies_with_metadata to falseactioncable → @rails/actioncable
activestorage → @rails/activestorage
rails-ujs → @rails/ujs
ActionCable.WebSocket = MyWebSocket
ActionCable.adapters.WebSocket = MyWebSocket
ActionCable.logger = myLogger
ActionCable.adapters.logger = myLogger
ActionCable.startDebugging()
ActionCable.logger.enabled = true
ActionCable.stopDebugging()
ActionCable.logger.enabled = false
.content_type now returns the charset.media_type to return just the mime typeconfig.hosts setting# config/environments/development.rb
config.hosts << "example.com"
# can also use regexp:
config.hosts << /[a-zA-Z0-9].example.com/
zeitwerk
require_directive statements are needed# config/application.rb
config.load_defaults 6.0
# if upgrdaing from older version of rails
# config/application.rb
config.autoloader :zeitwerk
app/models
app/models/concerns
app/models/concerns/foo.rb can now be defined as Foo and not
Concerns::Fooapp/api/base.rb, usually
defined as Api::Base will now be defined as just Base
ActiveSupport::Dependencies.autoload_paths.delete("#{Rails.root}/app/api")
config.cache_classes = false to turn enable reloading in the test envBootsnap should be atleast version 1.4.2# config/application.rb
config.load_defaults 6.0
config.autoloader = :classic
* `has_many_attached` used to append new files to the collection
* new behavior: overwrites the current collection
* use `attach` to add new attachments without overwriting the existing ones
rails7gem "rails", "~> 7.0", ">= 7.0.8.7"bundle updaterails app:update
button_towill now render a form_tag using a patch methodspring will need to be updated to v3.0+sprocket-rails has been dropped, will need to manually include if usingzeitwerk is now enabled by default (no more classic)