Rails

Rails 7 optimizes remove_columns to use a single SQL statement when supported

Rails 7 remove_columns will now trigger a single SQL statement to remove all columns if the database supports it, instead of querying multiple SQL statements for removing individual columns.

Rails 7 now consistently renders button_to

Rails 7 introduced a config that helps button_to consistently render out to the button HTML tag.

Starting with Rails 7, retry failed jobs indefinitely

Pass `:unlimited` symbol to `attempts` parameter of ActiveJob's `retry_on` method, which allows a developer to specify that a job should retry forever until it succeeds.

ActiveStorage now raises a PreviewError when previews fail to generate

Before this update, a failed preview generation would result in a 0-byte file being created – leading to disastrous outcomes in the views.

Rails 7 moves ActiveRecord::Base.logger to a class_attribute leading to a 7x speed improvement

Rails 7 utilized Ruby's cache for cvars to improve ActiveRecord::Base.logger performance 7x. Let's deep dive into this!

ActiveRecord::Calculations will now use column-based type casting

Rails 7 now harmonizes results of ActiveRecord::Calculations.average by applying column-based typecasting. Now, floating-point number columns will be aggregated as Float.

Rails 7 allows setting cache expiry, as an absolute timestamp

With the introduction of expires_at to Rails Cache it is now possible to set absolute timestamps for cache expiry.

Rails 7 adds change tracking methods for belongs_to associations

Rails 7 adds the ability to track if an association has been pointed to a new target record in the previous save and whether it will point to a new target record in the next save.

Rails 7 allows loading nested locales in the engine

Rails 7 allows loading nested locales inside the `/locales` directory by default for better organization in larger apps.

Rails 7 adds support for `if_exists/if_not_exists` on `remove_foreign_key/add_foreign_key`

Rails 7 adds support for `if_exists/if_not_exists` on `remove_foreign_key/add_foreign_key` in migrations to silently ignore raised exceptions.