1 Upgrading to Rails 7.0
If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 6.1 in case you haven't and make sure your application still runs as expected before attempting an update to Rails 7.0. A list of things to watch out for when upgrading is available in the Upgrading Ruby on Rails guide.
2 Major Features
3 Railties
Please refer to the Changelog for detailed changes.
3.1 Removals
- Remove deprecated
config
indbconsole
.
3.2 Deprecations
3.3 Notable changes
-
Sprockets is now an optional dependency
The gem
rails
doesn't depend onsprockets-rails
anymore. If your application still needs to use Sprockets, make sure to addsprockets-rails
to your Gemfile.gem "sprockets-rails"
4 Action Cable
Please refer to the Changelog for detailed changes.
4.1 Removals
4.2 Deprecations
4.3 Notable changes
5 Action Pack
Please refer to the Changelog for detailed changes.
5.1 Removals
Remove deprecated
ActionDispatch::Response.return_only_media_type_on_content_type
.Remove deprecated
Rails.config.action_dispatch.hosts_response_app
.Remove deprecated
ActionDispatch::SystemTestCase#host!
.Remove deprecated support to passing a path to
fixture_file_upload
relative tofixture_path
.
5.2 Deprecations
5.3 Notable changes
6 Action View
Please refer to the Changelog for detailed changes.
6.1 Removals
- Remove deprecated
Rails.config.action_view.raise_on_missing_translations
.
6.2 Deprecations
6.3 Notable changes
-
button_to
infers HTTP verb [method] from an Active Record object if object is used to build URLbutton_to("Do a POST", [:do_post_action, Workshop.find(1)]) # Before #=> <input type="hidden" name="_method" value="post" autocomplete="off" /> # After #=> <input type="hidden" name="_method" value="patch" autocomplete="off" />
7 Action Mailer
Please refer to the Changelog for detailed changes.
7.1 Removals
- Remove deprecated
ActionMailer::DeliveryJob
andActionMailer::Parameterized::DeliveryJob
in favor ofActionMailer::MailDeliveryJob
.
7.2 Deprecations
7.3 Notable changes
8 Active Record
Please refer to the Changelog for detailed changes.
8.1 Removals
Remove deprecated
database
kwarg fromconnected_to
.Remove deprecated
ActiveRecord::Base.allow_unsafe_raw_sql
.Remove deprecated option
:spec_name
in theconfigs_for
method.Remove deprecated support to YAML load
ActiveRecord::Base
instance in the Rails 4.2 and 4.1 formats.-
Remove deprecation warning when
:interval
column is used in PostgreSQL database.Now, interval columns will return
ActiveSupport::Duration
objects instead of strings.To keep the old behavior, you can add this line to your model:
attribute :column, :string
Remove deprecated support to resolve connection using
"primary"
as connection specification name.Remove deprecated support to quote
ActiveRecord::Base
objects.Remove deprecated support to type cast to database values
ActiveRecord::Base
objects.Remove deprecated support to pass a column to
type_cast
.Remove deprecated
DatabaseConfig#config
method.-
Remove deprecated rake tasks:
db:schema:load_if_ruby
db:structure:dump
db:structure:load
db:structure:load_if_sql
db:structure:dump:#{name}
db:structure:load:#{name}
db:test:load_structure
db:test:load_structure:#{name}
Remove deprecated support to
Model.reorder(nil).first
to search using non-deterministic order.Remove deprecated
environment
andname
arguments fromTasks::DatabaseTasks.schema_up_to_date?
.Remove deprecated
Tasks::DatabaseTasks.dump_filename
.Remove deprecated
Tasks::DatabaseTasks.schema_file
.Remove deprecated
Tasks::DatabaseTasks.spec
.Remove deprecated
Tasks::DatabaseTasks.current_config
.Remove deprecated
ActiveRecord::Connection#allowed_index_name_length
.Remove deprecated
ActiveRecord::Connection#in_clause_length
.Remove deprecated
ActiveRecord::DatabaseConfigurations::DatabaseConfig#spec_name
.
8.2 Deprecations
- Deprecated
Tasks::DatabaseTasks.schema_file_type
.
8.3 Notable changes
-
Rollback transactions when the block returns earlier than expected.
Before this change, when a transaction block returned early, the transaction would be committed.
The problem is that timeouts triggered inside the transaction block was also making the incomplete transaction to be committed, so in order to avoid this mistake, the transaction block is rolled back.
-
Merging conditions on the same column no longer maintain both conditions, and will be consistently replaced by the latter condition.
# Rails 6.1 (IN clause is replaced by merger side equality condition) Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob] # Rails 6.1 (both conflict conditions exists, deprecated) Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [] # Rails 6.1 with rewhere to migrate to Rails 7.0's behavior Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob] # Rails 7.0 (same behavior with IN clause, mergee side condition is consistently replaced) Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob] Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
9 Active Storage
Please refer to the Changelog for detailed changes.
9.1 Removals
9.2 Deprecations
9.3 Notable changes
10 Active Model
Please refer to the Changelog for detailed changes.
10.1 Removals
Remove deprecated enumeration of
ActiveModel::Errors
instances as a Hash.Remove deprecated
ActiveModel::Errors#to_h
.Remove deprecated
ActiveModel::Errors#slice!
.Remove deprecated
ActiveModel::Errors#values
.Remove deprecated
ActiveModel::Errors#keys
.Remove deprecated
ActiveModel::Errors#to_xml
.Remove deprecated support concat errors to
ActiveModel::Errors#messages
.Remove deprecated support to
clear
errors fromActiveModel::Errors#messages
.Remove deprecated support to
delete
errors fromActiveModel::Errors#messages
.Remove deprecated support to use
[]=
inActiveModel::Errors#messages
.Remove support to Marshal and YAML load Rails 5.x error format.
Remove support to Marshal load Rails 5.x
ActiveModel::AttributeSet
format.
10.2 Deprecations
10.3 Notable changes
11 Active Support
Please refer to the Changelog for detailed changes.
11.1 Removals
Remove deprecated
config.active_support.use_sha1_digests
.Remove deprecated
URI.parser
.Remove deprecated support to use
Range#include?
to check the inclusion of a value in a date time range is deprecated.Remove deprecate
ActiveSupport::Multibyte::Unicode.default_normalization_form
.
11.2 Deprecations
-
Deprecate passing a format to
#to_s
in favor of#to_formatted_s
inArray
,Range
,Date
,DateTime
,Time
,BigDecimal
,Float
and,Integer
.This deprecation is to allow Rails application to take advantage of a Ruby 3.1 [optimization][https://github.com/ruby/ruby/commit/b08dacfea39ad8da3f1fd7fdd0e4538cc892ec44] that makes interpolation of some types of objects faster.
New applications will not have the
#to_s
method overridden on those classes, existing applications can useconfig.active_support.disable_to_s_conversion
.
11.3 Notable changes
12 Active Job
Please refer to the Changelog for detailed changes.
12.1 Removals
Removed deprecated behavior that was not halting
after_enqueue
/after_perform
callbacks when a previous callback was halted withthrow :abort
.Remove deprecated
:return_false_on_aborted_enqueue
option.Remove deprecated
ActiveRecord::Base.connection_config
.Remove deprecated
ActiveRecord::Base.arel_attribute
.Remove deprecated
ActiveRecord::Base.configurations.default_hash
.Remove deprecated
ActiveRecord::Base.configurations.to_h
.Remove deprecated
ActiveRecord::Result#map!
andActiveRecord::Result#collect!
.Remove deprecated
ActiveRecord::Base#remove_connection
.
12.2 Deprecations
- Deprecated
Rails.config.active_job.skip_after_callbacks_if_terminated
.
12.3 Notable changes
13 Action Text
Please refer to the Changelog for detailed changes.
13.1 Removals
13.2 Deprecations
13.3 Notable changes
14 Action Mailbox
Please refer to the Changelog for detailed changes.
14.1 Removals
Removed deprecated
Rails.application.credentials.action_mailbox.mailgun_api_key
.Removed deprecated environment variable
MAILGUN_INGRESS_API_KEY
.
14.2 Deprecations
14.3 Notable changes
15 Ruby on Rails Guides
Please refer to the Changelog for detailed changes.
15.1 Notable changes
16 Credits
See the full list of contributors to Rails for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.
Feedback
You're encouraged to help improve the quality of this guide.
Please contribute if you see any typos or factual errors. To get started, you can read our documentation contributions section.
You may also find incomplete content or stuff that is not up to date. Please do add any missing documentation for main. Make sure to check Edge Guides first to verify if the issues are already fixed or not on the main branch. Check the Ruby on Rails Guides Guidelines for style and conventions.
If for whatever reason you spot something to fix but cannot patch it yourself, please open an issue.
And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome on the rubyonrails-docs mailing list.