diff --git a/Gemfile.lock b/Gemfile.lock index 4d6a3eaecc6..8c7e6ea0822 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,70 +20,70 @@ GIT PATH remote: . specs: - actioncable (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actioncable (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activestorage (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionmailbox (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activestorage (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - actionview (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionmailer (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + actionview (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.0.rc1) - actionview (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionpack (7.2.0.alpha) + actionview (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activestorage (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actiontext (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activestorage (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionview (7.2.0.alpha) + activesupport (= 7.2.0.alpha) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.0.rc1) - activesupport (= 7.1.0.rc1) + activejob (7.2.0.alpha) + activesupport (= 7.2.0.alpha) globalid (>= 0.3.6) - activemodel (7.1.0.rc1) - activesupport (= 7.1.0.rc1) - activerecord (7.1.0.rc1) - activemodel (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + activemodel (7.2.0.alpha) + activesupport (= 7.2.0.alpha) + activerecord (7.2.0.alpha) + activemodel (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) timeout (>= 0.4.0) - activestorage (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + activestorage (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) marcel (~> 1.0) - activesupport (7.1.0.rc1) + activesupport (7.2.0.alpha) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -93,23 +93,23 @@ PATH minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - rails (7.1.0.rc1) - actioncable (= 7.1.0.rc1) - actionmailbox (= 7.1.0.rc1) - actionmailer (= 7.1.0.rc1) - actionpack (= 7.1.0.rc1) - actiontext (= 7.1.0.rc1) - actionview (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activemodel (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activestorage (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + rails (7.2.0.alpha) + actioncable (= 7.2.0.alpha) + actionmailbox (= 7.2.0.alpha) + actionmailer (= 7.2.0.alpha) + actionpack (= 7.2.0.alpha) + actiontext (= 7.2.0.alpha) + actionview (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activemodel (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activestorage (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) bundler (>= 1.15.0) - railties (= 7.1.0.rc1) - railties (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + railties (= 7.2.0.alpha) + railties (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -557,7 +557,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS ruby diff --git a/RAILS_VERSION b/RAILS_VERSION index b104ec3500a..2031da2af56 100644 --- a/RAILS_VERSION +++ b/RAILS_VERSION @@ -1 +1 @@ -7.1.0.rc1 +7.2.0.alpha diff --git a/actioncable/CHANGELOG.md b/actioncable/CHANGELOG.md index 5de4305de47..8de6b43a843 100644 --- a/actioncable/CHANGELOG.md +++ b/actioncable/CHANGELOG.md @@ -1,106 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* No changes. - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Add a `@server` instance variable referencing the `ActionCable.server` - singleton to `ActionCable::Channel::ConnectionStub` - - This lets us delegate the `pubsub` and `config` method calls - to the server. This fixes `NoMethodError` errors when testing - channel logic that call `pubsub` (e.g. `stop_stream_for`). - - *Julian Foo* - -* Added `health_check_path` and `health_check_application` config to - mount a given health check rack app on a given path. - Useful when mounting Action Cable standalone. - - *Joé Dupuis* - -* Introduce the `capture_broadcasts` test helper. - - Returns all messages broadcast in a block. - - ```ruby - messages = capture_broadcasts("test") do - ActionCable.server.broadcast "test", { message: "one" } - ActionCable.server.broadcast "test", { message: "two" } - end - assert_equal 2, messages.length - assert_equal({ "message" => "one" }, messages.first) - assert_equal({ "message" => "two" }, messages.last) - ``` - - *Alex Ghiculescu* - -* Display broadcasted messages on error message when using `assert_broadcast_on` - - *Stéphane Robino* - -* The Action Cable client now supports subprotocols to allow passing arbitrary data - to the server. - - ```js - const consumer = ActionCable.createConsumer() - - consumer.addSubProtocol('custom-protocol') - - consumer.connect() - ``` - - See also: - - * https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#subprotocols - - *Guillaume Hain* - -* Redis pub/sub adapter now automatically reconnects when Redis connection is lost. - - *Vladimir Dementyev* - -* The `connected()` callback can now take a `{reconnected}` parameter to differentiate - connections from reconnections. - - ```js - import consumer from "./consumer" - - consumer.subscriptions.create("ExampleChannel", { - connected({reconnected}) { - if (reconnected) { - ... - } else { - ... - } - } - }) - ``` - - *Mansa Keïta* - -* The Redis adapter is now compatible with redis-rb 5.0 - - Compatibility with redis-rb 3.x was dropped. - - *Jean Boussier* - -* The Action Cable server is now mounted with `anchor: true`. - - This means that routes that also start with `/cable` will no longer clash with Action Cable. - - *Alex Ghiculescu* - -* `ActionCable.server.remote_connections.where(...).disconnect` now sends `disconnect` message - before closing the connection with the reconnection strategy specified (defaults to `true`). - - *Vladimir Dementyev* - -* Added command callbacks to `ActionCable::Connection::Base`. - - Now you can define `before_command`, `after_command`, and `around_command` to be invoked before, after or around any command received by a client respectively. - - *Vladimir Dementyev* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actioncable/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actioncable/CHANGELOG.md) for previous changes. diff --git a/actioncable/lib/action_cable/gem_version.rb b/actioncable/lib/action_cable/gem_version.rb index 4f24ace97cc..f1e674f4da7 100644 --- a/actioncable/lib/action_cable/gem_version.rb +++ b/actioncable/lib/action_cable/gem_version.rb @@ -8,9 +8,9 @@ module ActionCable module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actioncable/package.json b/actioncable/package.json index 0baa394d91d..fa95b242757 100644 --- a/actioncable/package.json +++ b/actioncable/package.json @@ -1,6 +1,6 @@ { "name": "@rails/actioncable", - "version": "7.1.0-rc1", + "version": "7.2.0-alpha", "description": "WebSocket framework for Ruby on Rails.", "module": "app/assets/javascripts/actioncable.esm.js", "main": "app/assets/javascripts/actioncable.js", diff --git a/actionmailbox/CHANGELOG.md b/actionmailbox/CHANGELOG.md index cf34b62ebca..56638356a0f 100644 --- a/actionmailbox/CHANGELOG.md +++ b/actionmailbox/CHANGELOG.md @@ -1,26 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* No changes. - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Added `bounce_now_with` to send the bounce email without going through a mailer queue. - - *Ronan Limon Duparcmeur* - -* Support configured primary key types in generated migrations. - - *Nishiki Liu* - -* Fixed ingress controllers' ability to accept emails that contain no UTF-8 encoded parts. - - Fixes #46297. - - *Jan Honza Sterba* - -* Add X-Forwarded-To addresses to recipients. - - *Andrew Stewart* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionmailbox/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionmailbox/CHANGELOG.md) for previous changes. diff --git a/actionmailbox/lib/action_mailbox/gem_version.rb b/actionmailbox/lib/action_mailbox/gem_version.rb index 12896d629e4..c3151ec7f4c 100644 --- a/actionmailbox/lib/action_mailbox/gem_version.rb +++ b/actionmailbox/lib/action_mailbox/gem_version.rb @@ -8,9 +8,9 @@ module ActionMailbox module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionmailbox/test/dummy/db/schema.rb b/actionmailbox/test/dummy/db/schema.rb index 87f8fde0b9a..34b275b341d 100644 --- a/actionmailbox/test/dummy/db/schema.rb +++ b/actionmailbox/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2018_02_12_164506) do +ActiveRecord::Schema[7.2].define(version: 2018_02_12_164506) do create_table "action_mailbox_inbound_emails", force: :cascade do |t| t.integer "status", default: 0, null: false t.string "message_id", null: false diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index 921ad101384..cff1fbb9c12 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,133 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Introduce `ActionMailer::FormBuilder` - - Use the `default_form_builder` method in mailers to set the default form builder - for templates rendered by that mailer. Matches the behaviour in Action Controller. - - *Alex Ghiculescu* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Mailers are listed in alphabetical order on the mailer preview page now. - - *Martin Spickermann* - -* Deprecate passing params to `assert_enqueued_email_with` via the `:args` - kwarg. `assert_enqueued_email_with` now supports a `:params` kwarg, so use - that to pass params: - - ```ruby - # BEFORE - assert_enqueued_email_with MyMailer, :my_method, args: { my_param: "value" } - - # AFTER - assert_enqueued_email_with MyMailer, :my_method, params: { my_param: "value" } - ``` - - To specify named mailer args as a Hash, wrap the Hash in an array: - - ```ruby - assert_enqueued_email_with MyMailer, :my_method, args: [{ my_arg: "value" }] - # OR - assert_enqueued_email_with MyMailer, :my_method, args: [my_arg: "value"] - ``` - - *Jonathan Hefner* - -* Accept procs for args and params in `assert_enqueued_email_with` - - ```ruby - assert_enqueued_email_with DeliveryJob, params: -> p { p[:token] =~ /\w+/ } do - UserMailer.with(token: user.generate_token).email_verification.deliver_later - end - ``` - - *Max Chernyak* - -* Added `*_deliver` callbacks to `ActionMailer::Base` that wrap mail message delivery. - - Example: - - ```ruby - class EventsMailer < ApplicationMailer - after_deliver do - User.find_by(email: message.to.first).update(email_provider_id: message.message_id, emailed_at: Time.current) - end - end - ``` - - *Ben Sheldon* - -* Added `deliver_enqueued_emails` to `ActionMailer::TestHelper`. This method - delivers all enqueued email jobs. - - Example: - - ```ruby - def test_deliver_enqueued_emails - deliver_enqueued_emails do - ContactMailer.welcome.deliver_later - end - assert_emails 1 - end - ``` - - *Andrew Novoselac* - -* The `deliver_later_queue_name` used by the default mailer job can now be - configured on a per-mailer basis. Previously this was only configurable - for all mailers via `ActionMailer::Base`. - - Example: - - ```ruby - class EventsMailer < ApplicationMailer - self.deliver_later_queue_name = :throttled_mailer - end - ``` - - *Jeffrey Hardy* - -* Email previews now include an expandable section to show all headers. - - Headers like `Message-ID` for threading or email service provider specific - features like analytics tags or account metadata can now be viewed directly - in the mailer preview. - - *Matt Swanson* - -* Default `ActionMailer::Parameterized#params` to an empty `Hash` - - *Sean Doyle* - -* Introduce the `capture_emails` test helper. - - Returns all emails that are sent in a block. - - ```ruby - def test_emails - emails = capture_emails do - ContactMailer.welcome.deliver_now - ContactMailer.welcome.deliver_later - end - assert_email "Hi there", emails.first.subject - end - ``` - - *Alex Ghiculescu* - -* Added ability to download `.eml` file for the email preview. - - *Igor Kasyanchuk* - -* Support multiple preview paths for mailers. - - Option `config.action_mailer.preview_path` is deprecated in favor of - `config.action_mailer.preview_paths`. Appending paths to this configuration option - will cause those paths to be used in the search for mailer previews. - - *fatkodima* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionmailer/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionmailer/CHANGELOG.md) for previous changes. diff --git a/actionmailer/lib/action_mailer/gem_version.rb b/actionmailer/lib/action_mailer/gem_version.rb index 5984e1ef565..a891c030b87 100644 --- a/actionmailer/lib/action_mailer/gem_version.rb +++ b/actionmailer/lib/action_mailer/gem_version.rb @@ -8,9 +8,9 @@ module ActionMailer module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 962552a9dd2..4ff4f1eb32c 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,532 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Add support for `#deep_merge` and `#deep_merge!` to - `ActionController::Parameters`. - - *Sean Doyle* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* `AbstractController::Translation.raise_on_missing_translations` removed - - This was a private API, and has been removed in favour of a more broadly applicable - `config.i18n.raise_on_missing_translations`. See the upgrading guide for more information. - - *Alex Ghiculescu* - -* Add `ActionController::Parameters#extract_value` method to allow extracting serialized values from params - - ```ruby - params = ActionController::Parameters.new(id: "1_123", tags: "ruby,rails") - params.extract_value(:id) # => ["1", "123"] - params.extract_value(:tags, delimiter: ",") # => ["ruby", "rails"] - ``` - - *Nikita Vasilevsky* - -* Parse JSON `response.parsed_body` with `ActiveSupport::HashWithIndifferentAccess` - - Integrate with Minitest's new `assert_pattern` by parsing the JSON contents - of `response.parsed_body` with `ActiveSupport::HashWithIndifferentAccess`, so - that it's pattern-matching compatible. - - *Sean Doyle* - -* Add support for Playwright as a driver for system tests. - - *Yuki Nishijima* - -* Fix `HostAuthorization` potentially displaying the value of the - X_FORWARDED_HOST header when the HTTP_HOST header is being blocked. - - *Hartley McGuire*, *Daniel Schlosser* - -* Rename `fixture_file_upload` method to `file_fixture_upload` - - Declare an alias to preserve the backwards compatibility of `fixture_file_upload` - - *Sean Doyle* - -* `ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper` saves the screenshot path in test metadata on failure. - - *Matija Čupić* - -* `config.dom_testing_default_html_version` controls the HTML parser used by - `ActionDispatch::Assertions#html_document`. - - The Rails 7.1 default configuration opts into the HTML5 parser when it is supported, to better - represent what the DOM would be in a browser user agent. Previously this test helper always used - Nokogiri's HTML4 parser. - - *Mike Dalessio* - -* The `with_routing` helper can now be called at the class level. When called at the class level, the routes will - be setup before each test, and reset after every test. For example: - - ```ruby - class RoutingTest < ActionController::TestCase - with_routing do |routes| - routes.draw do - resources :articles - resources :authors - end - end - - def test_articles_route - assert_routing("/articles", controller: "articles", action: "index") - end - - def test_authors_route - assert_routing("/authors", controller: "authors", action: "index") - end - end - ``` - - *Andrew Novoselac* - -* The `Mime::Type` now supports handling types with parameters and correctly handles quotes. - When parsing the accept header, the parameters before the q-parameter are kept and if a matching mime-type exists it is used. - To keep the current functionality, a fallback is created to look for the media-type without the parameters. - - This change allows for custom MIME-types that are more complex like `application/vnd.api+json; profile="https://jsonapi.org/profiles/ethanresnick/cursor-pagination/" ext="https://jsonapi.org/ext/atomic"` for the [JSON API](https://jsonapi.org/). - - *Nicolas Erni* - -* The url_for helpers now support a new option called `path_params`. - This is very useful in situations where you only want to add a required param that is part of the route's URL but for other route not append an extraneous query param. - - Given the following router... - - ```ruby - Rails.application.routes.draw do - scope ":account_id" do - get "dashboard" => "pages#dashboard", as: :dashboard - get "search/:term" => "search#search", as: :search - end - delete "signout" => "sessions#destroy", as: :signout - end - ``` - - And given the following `ApplicationController` - - ```ruby - class ApplicationController < ActionController::Base - def default_url_options - { path_params: { account_id: "foo" } } - end - end - ``` - - The standard url_for helper and friends will now behave as follows: - - ```ruby - dashboard_path # => /foo/dashboard - dashboard_path(account_id: "bar") # => /bar/dashboard - - signout_path # => /signout - signout_path(account_id: "bar") # => /signout?account_id=bar - signout_path(account_id: "bar", path_params: { account_id: "baz" }) # => /signout?account_id=bar - search_path("quin") # => /foo/search/quin - ``` - - *Jason Meller, Jeremy Beker* - -* Change `action_dispatch.show_exceptions` to one of `:all`, `:rescuable`, or - `:none`. `:all` and `:none` behave the same as the previous `true` and - `false` respectively. The new `:rescuable` option will only show exceptions - that can be rescued (e.g. `ActiveRecord::RecordNotFound`). `:rescuable` is - now the default for the test environment. - - *Jon Dufresne* - -* `config.action_dispatch.cookies_serializer` now accepts `:message_pack` and - `:message_pack_allow_marshal` as serializers. These serializers require the - [`msgpack` gem](https://rubygems.org/gems/msgpack) (>= 1.7.0). - - The Message Pack format can provide improved performance and smaller payload - sizes. It also supports roundtripping some Ruby types that are not supported - by JSON. For example: - - ```ruby - cookies.encrypted[:foo] = [{ a: 1 }, { b: 2 }.with_indifferent_access, 1.to_d, Time.at(0, 123)] - - # BEFORE with config.action_dispatch.cookies_serializer = :json - cookies.encrypted[:foo] - # => [{"a"=>1}, {"b"=>2}, "1.0", "1969-12-31T18:00:00.000-06:00"] - cookies.encrypted[:foo].map(&:class) - # => [Hash, Hash, String, String] - - # AFTER with config.action_dispatch.cookies_serializer = :message_pack - cookies.encrypted[:foo] - # => [{:a=>1}, {"b"=>2}, 0.1e1, 1969-12-31 18:00:00.000123 -0600] - cookies.encrypted[:foo].map(&:class) - # => [Hash, ActiveSupport::HashWithIndifferentAccess, BigDecimal, Time] - ``` - - The `:message_pack` serializer can fall back to deserializing with - `ActiveSupport::JSON` when necessary, and the `:message_pack_allow_marshal` - serializer can fall back to deserializing with `Marshal` as well as - `ActiveSupport::JSON`. Additionally, the `:marshal`, `:json`, and - `:json_allow_marshal` (AKA `:hybrid`) serializers can now fall back to - deserializing with `ActiveSupport::MessagePack` when necessary. These - behaviors ensure old cookies can still be read so that migration is easier. - - *Jonathan Hefner* - -* Remove leading dot from domains on cookies set with `domain: :all`, to meet RFC6265 requirements - - *Gareth Adams* - -* Include source location in routes extended view. - - ```bash - $ bin/rails routes --expanded - - ... - --[ Route 14 ]---------- - Prefix | new_gist - Verb | GET - URI | /gist(.:format) - Controller#Action | gists/gists#new - Source Location | config/routes/gist.rb:3 - ``` - - *Luan Vieira, John Hawthorn and Daniel Colson* - -* Add `without` as an alias of `except` on `ActiveController::Parameters`. - - *Hidde-Jan Jongsma* - -* Expand search field on `rails/info/routes` to also search **route name**, **http verb** and **controller#action**. - - *Jason Kotchoff* - -* Remove deprecated `poltergeist` and `webkit` (capybara-webkit) driver registration for system testing. - - *Rafael Mendonça França* - -* Remove deprecated ability to assign a single value to `config.action_dispatch.trusted_proxies`. - - *Rafael Mendonça França* - -* Deprecate `config.action_dispatch.return_only_request_media_type_on_content_type`. - - *Rafael Mendonça França* - -* Remove deprecated behavior on `Request#content_type`. - - *Rafael Mendonça França* - -* Change `ActionController::Instrumentation` to pass `filtered_path` instead of `fullpath` in the event payload to filter sensitive query params - - ```ruby - get "/posts?password=test" - request.fullpath # => "/posts?password=test" - request.filtered_path # => "/posts?password=[FILTERED]" - ``` - - *Ritikesh G* - -* Deprecate `AbstractController::Helpers::MissingHelperError` - - *Hartley McGuire* - -* Change `ActionDispatch::Testing::TestResponse#parsed_body` to parse HTML as - a Nokogiri document - - ```ruby - get "/posts" - response.content_type # => "text/html; charset=utf-8" - response.parsed_body.class # => Nokogiri::HTML5::Document - response.parsed_body.to_html # => "\n\n..." - ``` - - *Sean Doyle* - -* Deprecate `ActionDispatch::IllegalStateError`. - - *Samuel Williams* - -* Add HTTP::Request#route_uri_pattern that returns URI pattern of matched route. - - *Joel Hawksley*, *Kate Higa* - -* Add `ActionDispatch::AssumeSSL` middleware that can be turned on via `config.assume_ssl`. - It makes the application believe that all requests are arriving over SSL. This is useful - when proxying through a load balancer that terminates SSL, the forwarded request will appear - as though its HTTP instead of HTTPS to the application. This makes redirects and cookie - security target HTTP instead of HTTPS. This middleware makes the server assume that the - proxy already terminated SSL, and that the request really is HTTPS. - - *DHH* - -* Only use HostAuthorization middleware if `config.hosts` is not empty - - *Hartley McGuire* - -* Allow raising an error when a callback's only/unless symbols aren't existing methods. - - When `before_action :callback, only: :action_name` is declared on a controller that doesn't respond to `action_name`, raise an exception at request time. This is a safety measure to ensure that typos or forgetfulness don't prevent a crucial callback from being run when it should. - - For new applications, raising an error for undefined actions is turned on by default. If you do not want to opt-in to this behavior set `config.action_pack.raise_on_missing_callback_actions` to `false` in your application configuration. See #43487 for more details. - - *Jess Bees* - -* Allow cookie options[:domain] to accept a proc to set the cookie domain on a more flexible per-request basis - - *RobL* - -* When a host is not specified for an `ActionController::Renderer`'s env, - the host and related options will now be derived from the routes' - `default_url_options` and `ActionDispatch::Http::URL.secure_protocol`. - - This means that for an application with a configuration like: - - ```ruby - Rails.application.default_url_options = { host: "rubyonrails.org" } - Rails.application.config.force_ssl = true - ``` - - rendering a URL like: - - ```ruby - ApplicationController.renderer.render inline: "<%= blog_url %>" - ``` - - will now return `"https://rubyonrails.org/blog"` instead of - `"http://example.org/blog"`. - - *Jonathan Hefner* - -* Add details of cookie name and size to `CookieOverflow` exception. - - *Andy Waite* - -* Don't double log the `controller`, `action`, or `namespaced_controller` when using `ActiveRecord::QueryLog` - - Previously if you set `config.active_record.query_log_tags` to an array that included - `:controller`, `:namespaced_controller`, or `:action`, that item would get logged twice. - This bug has been fixed. - - *Alex Ghiculescu* - -* Add the following permissions policy directives: `hid`, `idle-detection`, `screen-wake-lock`, - `serial`, `sync-xhr`, `web-share`. - - *Guillaume Cabanel* - -* The `speaker`, `vibrate`, and `vr` permissions policy directives are now - deprecated. - - There is no browser support for these directives, and no plan for browser - support in the future. You can just remove these directives from your - application. - - *Jonathan Hefner* - -* Added the `:status` option to `assert_redirected_to` to specify the precise - HTTP status of the redirect. Defaults to `:redirect` for backwards - compatibility. - - *Jon Dufresne* - -* Rescue `JSON::ParserError` in Cookies JSON deserializer to discards marshal dumps: - - Without this change, if `action_dispatch.cookies_serializer` is set to `:json` and - the app tries to read a `:marshal` serialized cookie, it would error out which wouldn't - clear the cookie and force app users to manually clear it in their browser. - - (See #45127 for original bug discussion) - - *Nathan Bardoux* - -* Add `HTTP_REFERER` when following redirects on integration tests - - This makes `follow_redirect!` a closer simulation of what happens in a real browser - - *Felipe Sateler* - -* Added `exclude?` method to `ActionController::Parameters`. - - *Ian Neubert* - -* Rescue `EOFError` exception from `rack` on a multipart request. - - *Nikita Vasilevsky* - -* Log redirects from routes the same way as redirects from controllers. - - *Dennis Paagman* - -* Prevent `ActionDispatch::ServerTiming` from overwriting existing values in `Server-Timing`. - Previously, if another middleware down the chain set `Server-Timing` header, - it would overwritten by `ActionDispatch::ServerTiming`. - - *Jakub Malinowski* - -* Allow opting out of the `SameSite` cookie attribute when setting a cookie. - - You can opt out of `SameSite` by passing `same_site: nil`. - - `cookies[:foo] = { value: "bar", same_site: nil }` - - Previously, this incorrectly set the `SameSite` attribute to the value of the `cookies_same_site_protection` setting. - - *Alex Ghiculescu* - -* Allow using `helper_method`s in `content_security_policy` and `permissions_policy` - - Previously you could access basic helpers (defined in helper modules), but not - helper methods defined using `helper_method`. Now you can use either. - - ```ruby - content_security_policy do |p| - p.default_src "https://example.com" - p.script_src "https://example.com" if helpers.script_csp? - end - ``` - - *Alex Ghiculescu* - -* Reimplement `ActionController::Parameters#has_value?` and `#value?` to avoid parameters and hashes comparison. - - Deprecated equality between parameters and hashes is going to be removed in Rails 7.2. - The new implementation takes care of conversions. - - *Seva Stefkin* - -* Allow only String and Symbol keys in `ActionController::Parameters`. - Raise `ActionController::InvalidParameterKey` when initializing Parameters - with keys that aren't strings or symbols. - - *Seva Stefkin* - -* Add the ability to use custom logic for storing and retrieving CSRF tokens. - - By default, the token will be stored in the session. Custom classes can be - defined to specify arbitrary behavior, but the ability to store them in - encrypted cookies is built in. - - *Andrew Kowpak* - -* Make ActionController::Parameters#values cast nested hashes into parameters. - - *Gannon McGibbon* - -* Introduce `html:` and `screenshot:` kwargs for system test screenshot helper - - Use these as an alternative to the already-available environment variables. - - For example, this will display a screenshot in iTerm, save the HTML, and output - its path. - - ```ruby - take_screenshot(html: true, screenshot: "inline") - ``` - - *Alex Ghiculescu* - -* Allow `ActionController::Parameters#to_h` to receive a block. - - *Bob Farrell* - -* Allow relative redirects when `raise_on_open_redirects` is enabled - - *Tom Hughes* - -* Allow Content Security Policy DSL to generate for API responses. - - *Tim Wade* - -* Fix `authenticate_with_http_basic` to allow for missing password. - - Before Rails 7.0 it was possible to handle basic authentication with only a username. - - ```ruby - authenticate_with_http_basic do |token, _| - ApiClient.authenticate(token) - end - ``` - - This ability is restored. - - *Jean Boussier* - -* Fix `content_security_policy` returning invalid directives. - - Directives such as `self`, `unsafe-eval` and few others were not - single quoted when the directive was the result of calling a lambda - returning an array. - - ```ruby - content_security_policy do |policy| - policy.frame_ancestors lambda { [:self, "https://example.com"] } - end - ``` - - With this fix the policy generated from above will now be valid. - - *Edouard Chin* - -* Fix `skip_forgery_protection` to run without raising an error if forgery - protection has not been enabled / `verify_authenticity_token` is not a - defined callback. - - This fix prevents the Rails 7.0 Welcome Page (`/`) from raising an - `ArgumentError` if `default_protect_from_forgery` is false. - - *Brad Trick* - -* Make `redirect_to` return an empty response body. - - Application controllers that wish to add a response body after calling - `redirect_to` can continue to do so. - - *Jon Dufresne* - -* Use non-capturing group for subdomain matching in `ActionDispatch::HostAuthorization` - - Since we do nothing with the captured subdomain group, we can use a non-capturing group instead. - - *Sam Bostock* - -* Fix `ActionController::Live` to copy the IsolatedExecutionState in the ephemeral thread. - - Since its inception `ActionController::Live` has been copying thread local variables - to keep things such as `CurrentAttributes` set from middlewares working in the controller action. - - With the introduction of `IsolatedExecutionState` in 7.0, some of that global state was lost in - `ActionController::Live` controllers. - - *Jean Boussier* - -* Fix setting `trailing_slash: true` in route definition. - - ```ruby - get '/test' => "test#index", as: :test, trailing_slash: true - - test_path() # => "/test/" - ``` - - *Jean Boussier* - -* Make `Session#merge!` stringify keys. - - Previously `Session#update` would, but `merge!` wouldn't. - - *Drew Bragg* - -* Add `:unsafe_hashes` mapping for `content_security_policy` - - ```ruby - # Before - policy.script_src :strict_dynamic, "'unsafe-hashes'", "'sha256-rRMdkshZyJlCmDX27XnL7g3zXaxv7ei6Sg+yt4R3svU='" - - # After - policy.script_src :strict_dynamic, :unsafe_hashes, "'sha256-rRMdkshZyJlCmDX27XnL7g3zXaxv7ei6Sg+yt4R3svU='" - ``` - - *Igor Morozov* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionpack/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionpack/CHANGELOG.md) for previous changes. diff --git a/actionpack/lib/action_pack/gem_version.rb b/actionpack/lib/action_pack/gem_version.rb index e55c9386398..5d6e1aca1d1 100644 --- a/actionpack/lib/action_pack/gem_version.rb +++ b/actionpack/lib/action_pack/gem_version.rb @@ -8,9 +8,9 @@ module ActionPack module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actiontext/CHANGELOG.md b/actiontext/CHANGELOG.md index e19102a084a..f584fc58ed4 100644 --- a/actiontext/CHANGELOG.md +++ b/actiontext/CHANGELOG.md @@ -1,63 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* No changes. - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Use `Rails::HTML5::SafeListSanitizer` by default in the Rails 7.1 configuration if it is - supported. - - Action Text's sanitizer can be configured by setting - `config.action_text.sanitizer_vendor`. Supported values are `Rails::HTML4::Sanitizer` or - `Rails::HTML5::Sanitizer`. - - The Rails 7.1 configuration will set this to `Rails::HTML5::Sanitizer` when it is supported, and - fall back to `Rails::HTML4::Sanitizer`. Previous configurations default to - `Rails::HTML4::Sanitizer`. - - As a result of this change, the defaults for `ActionText::ContentHelper.allowed_tags` and - `.allowed_attributes` are applied at runtime, so the value of these attributes is now 'nil' - unless set by the application. You may call `sanitizer_allowed_tags` or - `sanitizer_allowed_attributes` to inspect the tags and attributes being allowed by the - sanitizer. - - *Mike Dalessio* - -* Attachables now can override default attachment missing template. - - When rendering Action Text attachments where the underlying attachable model has - been removed, a fallback template is used. You now can override this template on - a per-model basis. For example, you could render a placeholder image for a file - attachment or the text "Deleted User" for a User attachment. - - *Matt Swanson*, *Joel Drapper* - -* Update bundled Trix version from `1.3.1` to `2.0.4`. - - *Sarah Ridge*, *Sean Doyle* - -* Apply `field_error_proc` to `rich_text_area` form fields. - - *Kaíque Kandy Koga* - -* Action Text attachment URLs rendered in a background job (a la Turbo - Streams) now use `Rails.application.default_url_options` and - `Rails.application.config.force_ssl` instead of `http://example.org`. - - *Jonathan Hefner* - -* Support `strict_loading:` option for `has_rich_text` declaration - - *Sean Doyle* - -* Update ContentAttachment so that it can encapsulate arbitrary HTML content in a document. - - *Jamis Buck* - -* Fix an issue that caused the content layout to render multiple times when a - rich_text field was updated. - - *Jacob Herrington* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actiontext/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actiontext/CHANGELOG.md) for previous changes. diff --git a/actiontext/lib/action_text/gem_version.rb b/actiontext/lib/action_text/gem_version.rb index 83331c0f09e..d003935fbb9 100644 --- a/actiontext/lib/action_text/gem_version.rb +++ b/actiontext/lib/action_text/gem_version.rb @@ -8,9 +8,9 @@ module ActionText module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actiontext/package.json b/actiontext/package.json index a8a2b7219d5..5d4f52c9942 100644 --- a/actiontext/package.json +++ b/actiontext/package.json @@ -1,6 +1,6 @@ { "name": "@rails/actiontext", - "version": "7.1.0-rc1", + "version": "7.2.0-alpha", "description": "Edit and display rich text in Rails applications", "main": "app/assets/javascripts/actiontext.js", "type": "module", diff --git a/actiontext/test/dummy/db/schema.rb b/actiontext/test/dummy/db/schema.rb index 4f54ab17b99..00cdb967b01 100644 --- a/actiontext/test/dummy/db/schema.rb +++ b/actiontext/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2019_03_17_200724) do +ActiveRecord::Schema[7.2].define(version: 2019_03_17_200724) do create_table "action_text_rich_texts", force: :cascade do |t| t.string "name", null: false t.text "body" diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index a323f7108be..ed66f6466c5 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,392 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Introduce `ActionView::TestCase.register_parser` - - ```ruby - register_parser :rss, -> rendered { RSS::Parser.parse(rendered) } - - test "renders RSS" do - article = Article.create!(title: "Hello, world") - - render formats: :rss, partial: article - - assert_equal "Hello, world", rendered.rss.items.last.title - end - ``` - - By default, register parsers for `:html` and `:json`. - - *Sean Doyle* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Fix `simple_format` with blank `wrapper_tag` option returns plain html tag - - By default `simple_format` method returns the text wrapped with `

`. But if we explicitly specify - the `wrapper_tag: nil` in the options, it returns the text wrapped with `<>` tag. - - Before: - - ```ruby - simple_format("Hello World", {}, { wrapper_tag: nil }) - # <>Hello World - ``` - - After: - - ```ruby - simple_format("Hello World", {}, { wrapper_tag: nil }) - #

Hello World

- ``` - - *Akhil G Krishnan*, *Junichi Ito* - -* Don't double-encode nested `field_id` and `field_name` index values - - Pass `index: @options` as a default keyword argument to `field_id` and - `field_name` view helper methods. - - *Sean Doyle* - -* Allow opting in/out of `Link preload` headers when calling `stylesheet_link_tag` or `javascript_include_tag` - - ```ruby - # will exclude header, even if setting is enabled: - javascript_include_tag("http://example.com/all.js", preload_links_header: false) - - # will include header, even if setting is disabled: - stylesheet_link_tag("http://example.com/all.js", preload_links_header: true) - ``` - - *Alex Ghiculescu* - -* Stop generating `Link preload` headers once it has reached 1KB. - - Some proxies have trouble handling large headers, but more importantly preload links - have diminishing returns so it's preferable not to go overboard with them. - - If tighter control is needed, it's recommended to disable automatic generation of preloads - and to generate them manually from the controller or from a middleware. - - *Jean Boussier* - -* `simple_format` helper now handles a `:sanitize_options` - any extra options you want appending to the sanitize. - - Before: - ```ruby - simple_format("Continue") - # => "

Continue

" - ``` - - After: - ```ruby - simple_format("Continue", {}, { sanitize_options: { attributes: %w[target href] } }) - # => "

Continue

" - ``` - - *Andrei Andriichuk* - -* Add support for HTML5 standards-compliant sanitizers, and default to `Rails::HTML5::Sanitizer` - in the Rails 7.1 configuration if it is supported. - - Action View's HTML sanitizers can be configured by setting - `config.action_view.sanitizer_vendor`. Supported values are `Rails::HTML4::Sanitizer` or - `Rails::HTML5::Sanitizer`. - - The Rails 7.1 configuration will set this to `Rails::HTML5::Sanitizer` when it is supported, and - fall back to `Rails::HTML4::Sanitizer`. Previous configurations default to - `Rails::HTML4::Sanitizer`. - - *Mike Dalessio* - -* `config.dom_testing_default_html_version` controls the HTML parser used by - `ActionView::TestCase#document_root_element`, which creates the DOM used by the assertions in - Rails::Dom::Testing. - - The Rails 7.1 default configuration opts into the HTML5 parser when it is supported, to better - represent what the DOM would be in a browser user agent. Previously this test helper always used - Nokogiri's HTML4 parser. - - *Mike Dalessio* - -* Add support for the HTML picture tag. It supports passing a String, an Array or a Block. - Supports passing properties directly to the img tag via the `:image` key. - Since the picture tag requires an img tag, the last element you provide will be used for the img tag. - For complete control over the picture tag, a block can be passed, which will populate the contents of the tag accordingly. - - Can be used like this for a single source: - ```erb - <%= picture_tag("picture.webp") %> - ``` - which will generate the following: - ```html - - - - ``` - - For multiple sources: - ```erb - <%= picture_tag("picture.webp", "picture.png", :class => "mt-2", :image => { alt: "Image", class: "responsive-img" }) %> - ``` - will generate: - ```html - - - - Image - - ``` - - Full control via a block: - ```erb - <%= picture_tag(:class => "my-class") do %> - <%= tag(:source, :srcset => image_path("picture.webp")) %> - <%= tag(:source, :srcset => image_path("picture.png")) %> - <%= image_tag("picture.png", :alt => "Image") %> - <% end %> - ``` - will generate: - ```html - - - - Image - - ``` - - *Juan Pablo Balarini* - -* Remove deprecated support to passing instance variables as locals to partials. - - *Rafael Mendonça França* - -* Remove deprecated constant `ActionView::Path`. - - *Rafael Mendonça França* - -* Guard `token_list` calls from escaping HTML too often - - *Sean Doyle* - -* `select` can now be called with a single hash containing options and some HTML options - - Previously this would not work as expected: - - ```erb - <%= select :post, :author, authors, required: true %> - ``` - - Instead you needed to do this: - - ```erb - <%= select :post, :author, authors, {}, required: true %> - ``` - - Now, either form is accepted, for the following HTML attributes: `required`, `multiple`, `size`. - - *Alex Ghiculescu* - -* Datetime form helpers (`time_field`, `date_field`, `datetime_field`, `week_field`, `month_field`) now accept an instance of Time/Date/DateTime as `:value` option. - - Before: - ```erb - <%= form.datetime_field :written_at, value: Time.current.strftime("%Y-%m-%dT%T") %> - ``` - - After: - ```erb - <%= form.datetime_field :written_at, value: Time.current %> - ``` - - *Andrey Samsonov* - -* Choices of `select` can optionally contain html attributes as the last element - of the child arrays when using grouped/nested collections - - ```erb - <%= form.select :foo, [["North America", [["United States","US"],["Canada","CA"]], { disabled: "disabled" }]] %> - # => - ``` - - *Chris Gunther* - -* `check_box_tag` and `radio_button_tag` now accept `checked` as a keyword argument - - This is to make the API more consistent with the `FormHelper` variants. You can now - provide `checked` as a positional or keyword argument: - - ```erb - = check_box_tag "admin", "1", false - = check_box_tag "admin", "1", checked: false - - = radio_button_tag 'favorite_color', 'maroon', false - = radio_button_tag 'favorite_color', 'maroon', checked: false - ``` - - *Alex Ghiculescu* - -* Allow passing a class to `dom_id`. - You no longer need to call `new` when passing a class to `dom_id`. - This makes `dom_id` behave like `dom_class` in this regard. - Apart from saving a few keystrokes, it prevents Ruby from needing - to instantiate a whole new object just to generate a string. - - Before: - ```ruby - dom_id(Post) # => NoMethodError: undefined method `to_key' for Post:Class - ``` - - After: - ```ruby - dom_id(Post) # => "new_post" - ``` - - *Goulven Champenois* - -* Report `:locals` as part of the data returned by ActionView render instrumentation. - - Before: - ```ruby - { - identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb", - layout: "layouts/application" - } - ``` - - After: - ```ruby - { - identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb", - layout: "layouts/application", - locals: {foo: "bar"} - } - ``` - - *Aaron Gough* - -* Strip `break_sequence` at the end of `word_wrap`. - - This fixes a bug where `word_wrap` didn't properly strip off break sequences that had printable characters. - - For example, compare the outputs of this template: - - ```erb - # <%= word_wrap("11 22\n33 44", line_width: 2, break_sequence: "\n# ") %> - ``` - - Before: - - ``` - # 11 - # 22 - # - # 33 - # 44 - # - ``` - - After: - - ``` - # 11 - # 22 - # 33 - # 44 - ``` - - *Max Chernyak* - -* Allow templates to set strict `locals`. - - By default, templates will accept any `locals` as keyword arguments. To define what `locals` a template accepts, add a `locals` magic comment: - - ```erb - <%# locals: (message:) -%> - <%= message %> - ``` - - Default values can also be provided: - - ```erb - <%# locals: (message: "Hello, world!") -%> - <%= message %> - ``` - - Or `locals` can be disabled entirely: - - ```erb - <%# locals: () %> - ``` - - *Joel Hawksley* - -* Add `include_seconds` option for `datetime_local_field` - - This allows to omit seconds part in the input field, by passing `include_seconds: false` - - *Wojciech Wnętrzak* - -* Guard against `ActionView::Helpers::FormTagHelper#field_name` calls with nil - `object_name` arguments. For example: - - ```erb - <%= fields do |f| %> - <%= f.field_name :body %> - <% end %> - ``` - - *Sean Doyle* - -* Strings returned from `strip_tags` are correctly tagged `html_safe?` - - Because these strings contain no HTML elements and the basic entities are escaped, they are safe - to be included as-is as PCDATA in HTML content. Tagging them as html-safe avoids double-escaping - entities when being concatenated to a SafeBuffer during rendering. - - Fixes [rails/rails-html-sanitizer#124](https://github.com/rails/rails-html-sanitizer/issues/124) - - *Mike Dalessio* - -* Move `convert_to_model` call from `form_for` into `form_with` - - Now that `form_for` is implemented in terms of `form_with`, remove the - `convert_to_model` call from `form_for`. - - *Sean Doyle* - -* Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`. - - Escape dangerous characters in names of tags and names of attributes in the - tag helpers, following the XML specification. Rename the option - `:escape_attributes` to `:escape`, to simplify by applying the option to the - whole tag. - - *Álvaro Martín Fraguas* - -* Extend audio_tag and video_tag to accept Active Storage attachments. - - Now it's possible to write - - ```ruby - audio_tag(user.audio_file) - video_tag(user.video_file) - ``` - - Instead of - - ```ruby - audio_tag(polymorphic_path(user.audio_file)) - video_tag(polymorphic_path(user.video_file)) - ``` - - `image_tag` already supported that, so this follows the same pattern. - - *Matheus Richard* - -* Ensure models passed to `form_for` attempt to call `to_model`. - - *Sean Doyle* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionview/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionview/CHANGELOG.md) for previous changes. diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index 6eb3c504ff5..d7b711cf742 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -8,9 +8,9 @@ module ActionView module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionview/package.json b/actionview/package.json index 63139ea1624..c7d394fe0d2 100644 --- a/actionview/package.json +++ b/actionview/package.json @@ -1,6 +1,6 @@ { "name": "@rails/ujs", - "version": "7.1.0-rc1", + "version": "7.2.0-alpha", "description": "Ruby on Rails unobtrusive scripting adapter", "main": "app/assets/javascripts/rails-ujs.js", "module": "app/assets/javascripts/rails-ujs.esm.js", diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index a46916f79d8..ba6d525b207 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -1,224 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Set `scheduled_at` attribute as a Time object instead of epoch seconds, and serialize and deserialize the value - when enqueued. Assigning a numeric/epoch value to scheduled_at= is deprecated; use a Time object instead. - - Deserializes `enqueued_at` as a Time instead of ISO8601 String. - - *Ben Sheldon* - -* Clarify the backoff strategy for the recommended `:wait` option when retrying jobs - - `wait: :exponentially_longer` is waiting polynomially longer, so it is now recommended to use `wait: :polynomially_longer` to keep the same behavior. - - *Victor Mours* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Fix Active Job log message to correctly report a job failed to enqueue - when the adapter raises an `ActiveJob::EnqueueError`. - - *Ben Sheldon* - -* Add `after_discard` method. - - This method lets job authors define a block which will be run when a job is about to be discarded. For example: - - ```ruby - class AfterDiscardJob < ActiveJob::Base - after_discard do |job, exception| - Rails.logger.info("#{job.class} raised an exception: #{exception}") - end - - def perform - raise StandardError - end - end - ``` - - The above job will run the block passed to `after_discard` after the job is discarded. The exception will - still be raised after the block has been run. - - *Rob Cardy* - -* Fix deserialization of ActiveSupport::Duration - - Previously, a deserialized Duration would return an array from Duration#parts. - It will now return a hash just like a regular Duration. - - This also fixes an error when trying to add or subtract from a deserialized Duration - (eg `duration + 1.year`). - - *Jonathan del Strother* - -* `perform_enqueued_jobs` is now compatible with all Active Job adapters - - This means that methods that depend on it, like Action Mailer's `assert_emails`, - will work correctly even if the test adapter is not used. - - *Alex Ghiculescu* - -* Allow queue adapters to provide a custom name by implementing `queue_adapter_name` - - *Sander Verdonschot* - -* Log background job enqueue callers - - Add `verbose_enqueue_logs` configuration option to display the caller - of background job enqueue in the log to help with debugging. - - Example log line: - - ``` - Enqueued AvatarThumbnailsJob (Job ID: ab528951-41fb-4c48-9129-3171791c27d6) to Sidekiq(default) with arguments: 1092412064 - ↳ app/models/user.rb:421:in `generate_avatar_thumbnails' - ``` - - Enabled in development only for new and upgraded applications. Not recommended for use - in the production environment since it relies on Ruby's `Kernel#caller` which is fairly slow. - - *fatkodima* - -* Set `provider_job_id` for Backburner jobs - - *Cameron Matheson* - -* Add `perform_all_later` to enqueue multiple jobs at once - - This adds the ability to bulk enqueue jobs, without running callbacks, by - passing multiple jobs or an array of jobs. For example: - - ```ruby - ActiveJob.perform_all_later(MyJob.new("hello", 42), MyJob.new("world", 0)) - - user_jobs = User.pluck(:id).map { |id| UserJob.new(user_id: id) } - ActiveJob.perform_all_later(user_jobs) - ``` - - This can greatly reduce the number of round-trips to the queue datastore. - For queue adapters that do not implement the new `enqueue_all` method, we - fall back to enqueuing jobs individually. The Sidekiq adapter implements - `enqueue_all` with `push_bulk`. - - This method does not use the existing `enqueue.active_job` event, but adds a - new event `enqueue_all.active_job`. - - *Sander Verdonschot* - -* Don't double log the `job` when using `ActiveRecord::QueryLog` - - Previously if you set `config.active_record.query_log_tags` to an array that included - `:job`, the job name would get logged twice. This bug has been fixed. - - *Alex Ghiculescu* - -* Add support for Sidekiq's transaction-aware client - - *Jonathan del Strother* - -* Remove QueAdapter from Active Job. - - After maintaining Active Job QueAdapter by Rails and Que side - to support Ruby 3 keyword arguments and options provided as top level keywords, - it is quite difficult to maintain it this way. - - Active Job Que adapter can be included in the future version of que gem itself. - - *Yasuo Honda* - -* Fix BigDecimal (de)serialization for adapters using JSON. - - Previously, BigDecimal was listed as not needing a serializer. However, - when used with an adapter storing the job arguments as JSON, it would get - serialized as a simple String, resulting in deserialization also producing - a String (instead of a BigDecimal). - - By using a serializer, we ensure the round trip is safe. - - To ensure applications using BigDecimal job arguments are not subject to - race conditions during deployment (where a replica running a version of - Rails without BigDecimalSerializer fails to deserialize an argument - serialized with it), `ActiveJob.use_big_decimal_serializer` is disabled by - default, and can be set to true in a following deployment.. - - *Sam Bostock* - -* Preserve full-precision `enqueued_at` timestamps for serialized jobs, - allowing more accurate reporting of how long a job spent waiting in the - queue before it was performed. - - Retains IS08601 format compatibility. - - *Jeremy Daer* - -* Add `--parent` option to job generator to specify parent class of job. - - Example: - - `bin/rails g job process_payment --parent=payment_job` generates: - - ```ruby - class ProcessPaymentJob < PaymentJob - # ... - end - ``` - - *Gannon McGibbon* - -* Add more detailed description to job generator. - - *Gannon McGibbon* - -* `perform.active_job` notification payloads now include `:db_runtime`, which - is the total time (in ms) taken by database queries while performing a job. - This value can be used to better understand how a job's time is spent. - - *Jonathan Hefner* - -* Update `ActiveJob::QueueAdapters::QueAdapter` to remove deprecation warning. - - Remove a deprecation warning introduced in que 1.2 to prepare for changes in - que 2.0 necessary for Ruby 3 compatibility. - - *Damir Zekic* and *Adis Hasovic* - -* Add missing `bigdecimal` require in `ActiveJob::Arguments` - - Could cause `uninitialized constant ActiveJob::Arguments::BigDecimal (NameError)` - when loading Active Job in isolation. - - *Jean Boussier* - -* Allow testing `discard_on/retry_on ActiveJob::DeserializationError` - - Previously in `perform_enqueued_jobs`, `deserialize_arguments_if_needed` - was called before calling `perform_now`. When a record no longer exists - and is serialized using GlobalID this led to raising - an `ActiveJob::DeserializationError` before reaching `perform_now` call. - This behavior makes difficult testing the job `discard_on/retry_on` logic. - - Now `deserialize_arguments_if_needed` call is postponed to when `perform_now` - is called. - - Example: - - ```ruby - class UpdateUserJob < ActiveJob::Base - discard_on ActiveJob::DeserializationError - - def perform(user) - # ... - end - end - - # In the test - User.destroy_all - assert_nothing_raised do - perform_enqueued_jobs only: UpdateUserJob - end - ``` - - *Jacopo Beschi* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activejob/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activejob/CHANGELOG.md) for previous changes. diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index ede7a2fbbc6..ef81c3ee0b2 100644 --- a/activejob/lib/active_job/gem_version.rb +++ b/activejob/lib/active_job/gem_version.rb @@ -8,9 +8,9 @@ module ActiveJob module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index ba7cc89b557..16701b065e7 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,217 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Remove change in the typography of user facing error messages. - For example, “can’t be blank” is again “can't be blank”. - - *Rafael Mendonça França* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Support composite identifiers in `to_key` - - `to_key` avoids wrapping `#id` value into an `Array` if `#id` already an array - - *Nikita Vasilevsky* - -* Add `ActiveModel::Conversion.param_delimiter` to configure delimiter being used in `to_param` - - *Nikita Vasilevsky* - -* `undefine_attribute_methods` undefines alias attribute methods along with attribute methods. - - *Nikita Vasilevsky* - -* Error.full_message now strips ":base" from the message. - - *zzak* - -* Add a load hook for `ActiveModel::Model` (named `active_model`) to match the load hook for - `ActiveRecord::Base` and allow for overriding aspects of the `ActiveModel::Model` class. - - *Lewis Buckley* - -* Improve password length validation in ActiveModel::SecurePassword to consider byte size for BCrypt - compatibility. - - The previous password length validation only considered the character count, which may not - accurately reflect the 72-byte size limit imposed by BCrypt. This change updates the validation - to consider both character count and byte size while keeping the character length validation in place. - - ```ruby - user = User.new(password: "a" * 73) # 73 characters - user.valid? # => false - user.errors[:password] # => ["is too long"] - - - user = User.new(password: "あ" * 25) # 25 characters, 75 bytes - user.valid? # => false - user.errors[:password] # => ["is too long"] - ``` - - *ChatGPT*, *Guillermo Iguaran* - -* `has_secure_password` now generates an `#{attribute}_salt` method that returns the salt - used to compute the password digest. The salt will change whenever the password is changed, - so it can be used to create single-use password reset tokens with `generates_token_for`: - - ```ruby - class User < ActiveRecord::Base - has_secure_password - - generates_token_for :password_reset, expires_in: 15.minutes do - password_salt&.last(10) - end - end - ``` - - *Lázaro Nixon* - -* Improve typography of user facing error messages. In English contractions, - the Unicode APOSTROPHE (`U+0027`) is now RIGHT SINGLE QUOTATION MARK - (`U+2019`). For example, "can't be blank" is now "can’t be blank". - - *Jon Dufresne* - -* Add class to `ActiveModel::MissingAttributeError` error message. - - Show which class is missing the attribute in the error message: - - ```ruby - user = User.first - user.pets.select(:id).first.user_id - # => ActiveModel::MissingAttributeError: missing attribute 'user_id' for Pet - ``` - - *Petrik de Heus* - -* Raise `NoMethodError` in `ActiveModel::Type::Value#as_json` to avoid unpredictable - results. - - *Vasiliy Ermolovich* - -* Custom attribute types that inherit from Active Model built-in types and do - not override the `serialize` method will now benefit from an optimization - when serializing attribute values for the database. - - For example, with a custom type like the following: - - ```ruby - class DowncasedString < ActiveModel::Type::String - def cast(value) - super&.downcase - end - end - - ActiveRecord::Type.register(:downcased_string, DowncasedString) - - class User < ActiveRecord::Base - attribute :email, :downcased_string - end - - user = User.new(email: "FooBar@example.com") - ``` - - Serializing the `email` attribute for the database will be roughly twice as - fast. More expensive `cast` operations will likely see greater improvements. - - *Jonathan Hefner* - -* `has_secure_password` now supports password challenges via a - `password_challenge` accessor and validation. - - A password challenge is a safeguard to verify that the current user is - actually the password owner. It can be used when changing sensitive model - fields, such as the password itself. It is different than a password - confirmation, which is used to prevent password typos. - - When `password_challenge` is set, the validation checks that the value's - digest matches the *currently persisted* `password_digest` (i.e. - `password_digest_was`). - - This allows a password challenge to be done as part of a typical `update` - call, just like a password confirmation. It also allows a password - challenge error to be handled in the same way as other validation errors. - - For example, in the controller, instead of: - - ```ruby - password_params = params.require(:password).permit( - :password_challenge, - :password, - :password_confirmation, - ) - - password_challenge = password_params.delete(:password_challenge) - @password_challenge_failed = !current_user.authenticate(password_challenge) - - if !@password_challenge_failed && current_user.update(password_params) - # ... - end - ``` - - You can now write: - - ```ruby - password_params = params.require(:password).permit( - :password_challenge, - :password, - :password_confirmation, - ).with_defaults(password_challenge: "") - - if current_user.update(password_params) - # ... - end - ``` - - And, in the view, instead of checking `@password_challenge_failed`, you can - render an error for the `password_challenge` field just as you would for - other form fields, including utilizing `config.action_view.field_error_proc`. - - *Jonathan Hefner* - -* Support infinite ranges for `LengthValidator`s `:in`/`:within` options - - ```ruby - validates_length_of :first_name, in: ..30 - ``` - - *fatkodima* - -* Add support for beginless ranges to inclusivity/exclusivity validators: - - ```ruby - validates_inclusion_of :birth_date, in: -> { (..Date.today) } - ``` - - ```ruby - validates_exclusion_of :birth_date, in: -> { (..Date.today) } - ``` - - *Bo Jeanes* - -* Make validators accept lambdas without record argument - - ```ruby - # Before - validates_comparison_of :birth_date, less_than_or_equal_to: ->(_record) { Date.today } - - # After - validates_comparison_of :birth_date, less_than_or_equal_to: -> { Date.today } - ``` - - *fatkodima* - -* Fix casting long strings to `Date`, `Time` or `DateTime` - - *fatkodima* - -* Use different cache namespace for proxy calls - - Models can currently have different attribute bodies for the same method - names, leading to conflicts. Adding a new namespace `:active_model_proxy` - fixes the issue. - - *Chris Salzberg* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activemodel/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activemodel/CHANGELOG.md) for previous changes. diff --git a/activemodel/lib/active_model/gem_version.rb b/activemodel/lib/active_model/gem_version.rb index 8bdba679efe..d1d8f256d1d 100644 --- a/activemodel/lib/active_model/gem_version.rb +++ b/activemodel/lib/active_model/gem_version.rb @@ -8,9 +8,9 @@ module ActiveModel module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 358424afabc..e54105e6580 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,2244 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Better naming for unique constraints support. - - Naming unique keys leads to misunderstanding it's a short-hand of unique indexes. - Just naming it unique constraints is not misleading. - - In Rails 7.1.0.beta1 or before: - - ```ruby - add_unique_key :sections, [:position], deferrable: :deferred, name: "unique_section_position" - remove_unique_key :sections, name: "unique_section_position" - ``` - - Now: - - ```ruby - add_unique_constraint :sections, [:position], deferrable: :deferred, name: "unique_section_position" - remove_unique_constraint :sections, name: "unique_section_position" - ``` - - *Ryuta Kamizono* - -* Fix duplicate quoting for check constraint expressions in schema dump when using MySQL - - A check constraint with an expression, that already contains quotes, lead to an invalid schema - dump with the mysql2 adapter. - - Fixes #42424. - - *Felix Tscheulin* - -* Performance tune the SQLite3 adapter connection configuration - - For Rails applications, the Write-Ahead-Log in normal syncing mode with a capped journal size, a healthy shared memory buffer and a shared cache will perform, on average, 2× better. - - *Stephen Margheim* - -* Allow SQLite3 `busy_handler` to be configured with simple max number of `retries` - - Retrying busy connections without delay is a preferred practice for performance-sensitive applications. Add support for a `database.yml` `retries` integer, which is used in a simple `busy_handler` function to retry busy connections without exponential backoff up to the max number of `retries`. - - *Stephen Margheim* - -* The SQLite3 adapter now supports `supports_insert_returning?` - - Implementing the full `supports_insert_returning?` contract means the SQLite3 adapter supports auto-populated columns (#48241) as well as custom primary keys. - - *Stephen Margheim* - -* Ensure the SQLite3 adapter handles default functions with the `||` concatenation operator - - Previously, this default function would produce the static string `"'Ruby ' || 'on ' || 'Rails'"`. - Now, the adapter will appropriately receive and use `"Ruby on Rails"`. - - ```ruby - change_column_default "test_models", "ruby_on_rails", -> { "('Ruby ' || 'on ' || 'Rails')" } - ``` - - *Stephen Margheim* - -* Dump PostgreSQL schemas as part of the schema dump. - - *Lachlan Sylvester* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Encryption now supports `support_unencrypted_data` being set per-attribute. - - You can now opt out of `support_unencrypted_data` on a specific encrypted attribute. - This only has an effect if `ActiveRecord::Encryption.config.support_unencrypted_data == true`. - - ```ruby - class User < ActiveRecord::Base - encrypts :name, deterministic: true, support_unencrypted_data: false - encrypts :email, deterministic: true - end - ``` - - *Alex Ghiculescu* - -* Add instrumentation for Active Record transactions - - Allows subscribing to transaction events for tracking/instrumentation. The event payload contains the connection and the outcome (commit, rollback, restart, incomplete), as well as timing details. - - ```ruby - ActiveSupport::Notifications.subscribe("transaction.active_record") do |event| - puts "Transaction event occurred!" - connection = event.payload[:connection] - puts "Connection: #{connection.inspect}" - end - ``` - - *Daniel Colson*, *Ian Candy* - -* Support composite foreign keys via migration helpers. - - ```ruby - # Assuming "carts" table has "(shop_id, user_id)" as a primary key. - - add_foreign_key(:orders, :carts, primary_key: [:shop_id, :user_id]) - - remove_foreign_key(:orders, :carts, primary_key: [:shop_id, :user_id]) - foreign_key_exists?(:orders, :carts, primary_key: [:shop_id, :user_id]) - ``` - - *fatkodima* - -* Adds support for `if_not_exists` when adding a check constraint. - - ```ruby - add_check_constraint :posts, "post_type IN ('blog', 'comment', 'share')", if_not_exists: true - ``` - - *Cody Cutrer* - -* Raise an `ArgumentError` when `#accepts_nested_attributes_for` is declared more than once for an association in - the same class. Previously, the last declaration would silently override the previous one. Overriding in a subclass - is still allowed. - - *Joshua Young* - -* Deprecate `rewhere` argument on `#merge`. - - The `rewhere` argument on `#merge`is deprecated without replacement and - will be removed in Rails 7.2. - - *Adam Hess* - -* Fix unscope is not working in specific case - - Before: - ```ruby - Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM `posts` WHERE `posts`.`id` >= 1 AND `posts`.`id` < 3" - - ``` - - After: - ```ruby - Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM `posts`" - ``` - - Fixes #48094. - - *Kazuya Hatanaka* - -* Change `has_secure_token` default to `on: :initialize` - - Change the new default value from `on: :create` to `on: :initialize` - - Can be controlled by the `config.active_record.generate_secure_token_on` - configuration: - - ```ruby - config.active_record.generate_secure_token_on = :create - ``` - - *Sean Doyle* - -* Fix `change_column` not setting `precision: 6` on `datetime` columns when - using 7.0+ Migrations and SQLite. - - *Hartley McGuire* - -* Support composite identifiers in `to_key` - - `to_key` avoids wrapping `#id` value into an `Array` if `#id` already an array - - *Nikita Vasilevsky* - -* Add validation option for `enum` - - ```ruby - class Contract < ApplicationRecord - enum :status, %w[in_progress completed], validate: true - end - Contract.new(status: "unknown").valid? # => false - Contract.new(status: nil).valid? # => false - Contract.new(status: "completed").valid? # => true - - class Contract < ApplicationRecord - enum :status, %w[in_progress completed], validate: { allow_nil: true } - end - Contract.new(status: "unknown").valid? # => false - Contract.new(status: nil).valid? # => true - Contract.new(status: "completed").valid? # => true - ``` - - *Edem Topuzov*, *Ryuta Kamizono* - -* Allow batching methods to use already loaded relation if available - - Calling batch methods on already loaded relations will use the records previously loaded instead of retrieving - them from the database again. - - *Adam Hess* - -* Deprecate `read_attribute(:id)` returning the primary key if the primary key is not `:id`. - - Starting in Rails 7.2, `read_attribute(:id)` will return the value of the id column, regardless of the model's - primary key. To retrieve the value of the primary key, use `#id` instead. `read_attribute(:id)` for composite - primary key models will now return the value of the id column. - - *Adrianna Chang* - -* Fix `change_table` setting datetime precision for 6.1 Migrations - - *Hartley McGuire* - -* Fix change_column setting datetime precision for 6.1 Migrations - - *Hartley McGuire* - -* Add `ActiveRecord::Base#id_value` alias to access the raw value of a record's id column. - - This alias is only provided for models that declare an `:id` column. - - *Adrianna Chang* - -* Fix previous change tracking for `ActiveRecord::Store` when using a column with JSON structured database type - - Before, the methods to access the changes made during the last save `#saved_change_to_key?`, `#saved_change_to_key`, and `#key_before_last_save` did not work if the store was defined as a `store_accessor` on a column with a JSON structured database type - - *Robert DiMartino* - -* Fully support `NULLS [NOT] DISTINCT` for PostgreSQL 15+ indexes. - - Previous work was done to allow the index to be created in a migration, but it was not - supported in schema.rb. Additionally, the matching for `NULLS [NOT] DISTINCT` was not - in the correct order, which could have resulted in inconsistent schema detection. - - *Gregory Jones* - -* Allow escaping of literal colon characters in `sanitize_sql_*` methods when named bind variables are used - - *Justin Bull* - -* Fix `#previously_new_record?` to return true for destroyed records. - - Before, if a record was created and then destroyed, `#previously_new_record?` would return true. - Now, any UPDATE or DELETE to a record is considered a change, and will result in `#previously_new_record?` - returning false. - - *Adrianna Chang* - -* Specify callback in `has_secure_token` - - ```ruby - class User < ApplicationRecord - has_secure_token on: :initialize - end - - User.new.token # => "abc123...." - ``` - - *Sean Doyle* - -* Fix incrementation of in memory counter caches when associations overlap - - When two associations had a similarly named counter cache column, Active Record - could sometime increment the wrong one. - - *Jacopo Beschi*, *Jean Boussier* - -* Don't show secrets for Active Record's `Cipher::Aes256Gcm#inspect`. - - Before: - - ```ruby - ActiveRecord::Encryption::Cipher::Aes256Gcm.new(secret).inspect - "#" - ``` - - After: - - ```ruby - ActiveRecord::Encryption::Cipher::Aes256Gcm(secret).inspect - "#" - ``` - - *Petrik de Heus* - -* Bring back the historical behavior of committing transaction on non-local return. - - ```ruby - Model.transaction do - model.save - return - other_model.save # not executed - end - ``` - - Historically only raised errors would trigger a rollback, but in Ruby `2.3`, the `timeout` library - started using `throw` to interrupt execution which had the adverse effect of committing open transactions. - - To solve this, in Active Record 6.1 the behavior was changed to instead rollback the transaction as it was safer - than to potentially commit an incomplete transaction. - - Using `return`, `break` or `throw` inside a `transaction` block was essentially deprecated from Rails 6.1 onwards. - - However with the release of `timeout 0.4.0`, `Timeout.timeout` now raises an error again, and Active Record is able - to return to its original, less surprising, behavior. - - This historical behavior can now be opt-ed in via: - - ``` - Rails.application.config.active_record.commit_transaction_on_non_local_return = true - ``` - - And is the default for new applications created in Rails 7.1. - - *Jean Boussier* - -* Deprecate `name` argument on `#remove_connection`. - - The `name` argument is deprecated on `#remove_connection` without replacement. `#remove_connection` should be called directly on the class that established the connection. - - *Eileen M. Uchitelle* - -* Fix has_one through singular building with inverse. - - Allows building of records from an association with a has_one through a - singular association with inverse. For belongs_to through associations, - linking the foreign key to the primary key model isn't needed. - For has_one, we cannot build records due to the association not being mutable. - - *Gannon McGibbon* - -* Disable database prepared statements when query logs are enabled - - Prepared Statements and Query Logs are incompatible features due to query logs making every query unique. - - *zzak, Jean Boussier* - -* Support decrypting data encrypted non-deterministically with a SHA1 hash digest. - - This adds a new Active Record encryption option to support decrypting data encrypted - non-deterministically with a SHA1 hash digest: - - ``` - Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = true - ``` - - The new option addresses a problem when upgrading from 7.0 to 7.1. Due to a bug in how Active Record - Encryption was getting initialized, the key provider used for non-deterministic encryption were using - SHA-1 as its digest class, instead of the one configured globally by Rails via - `Rails.application.config.active_support.key_generator_hash_digest_class`. - - *Cadu Ribeiro and Jorge Manrubia* - -* Added PostgreSQL migration commands for enum rename, add value, and rename value. - - `rename_enum` and `rename_enum_value` are reversible. Due to Postgres - limitation, `add_enum_value` is not reversible since you cannot delete enum - values. As an alternative you should drop and recreate the enum entirely. - - ```ruby - rename_enum :article_status, to: :article_state - ``` - - ```ruby - add_enum_value :article_state, "archived" # will be at the end of existing values - add_enum_value :article_state, "in review", before: "published" - add_enum_value :article_state, "approved", after: "in review" - ``` - - ```ruby - rename_enum_value :article_state, from: "archived", to: "deleted" - ``` - - *Ray Faddis* - -* Allow composite primary key to be derived from schema - - Booting an application with a schema that contains composite primary keys - will not issue warning and won't `nil`ify the `ActiveRecord::Base#primary_key` value anymore. - - Given a `travel_routes` table definition and a `TravelRoute` model like: - ```ruby - create_table :travel_routes, primary_key: [:origin, :destination], force: true do |t| - t.string :origin - t.string :destination - end - - class TravelRoute < ActiveRecord::Base; end - ``` - The `TravelRoute.primary_key` value will be automatically derived to `["origin", "destination"]` - - *Nikita Vasilevsky* - -* Include the `connection_pool` with exceptions raised from an adapter. - - The `connection_pool` provides added context such as the connection used - that led to the exception as well as which role and shard. - - *Luan Vieira* - -* Support multiple column ordering for `find_each`, `find_in_batches` and `in_batches`. - - When find_each/find_in_batches/in_batches are performed on a table with composite primary keys, ascending or descending order can be selected for each key. - - ```ruby - Person.find_each(order: [:desc, :asc]) do |person| - person.party_all_night! - end - ``` - - *Takuya Kurimoto* - -* Fix where on association with has_one/has_many polymorphic relations. - - Before: - ```ruby - Treasure.where(price_estimates: PriceEstimate.all) - #=> SELECT (...) WHERE "treasures"."id" IN (SELECT "price_estimates"."estimate_of_id" FROM "price_estimates") - ``` - - Later: - ```ruby - Treasure.where(price_estimates: PriceEstimate.all) - #=> SELECT (...) WHERE "treasures"."id" IN (SELECT "price_estimates"."estimate_of_id" FROM "price_estimates" WHERE "price_estimates"."estimate_of_type" = 'Treasure') - ``` - - *Lázaro Nixon* - -* Assign auto populated columns on Active Record record creation. - - Changes record creation logic to allow for the `auto_increment` column to be assigned - immediately after creation regardless of it's relation to the model's primary key. - - The PostgreSQL adapter benefits the most from the change allowing for any number of auto-populated - columns to be assigned on the object immediately after row insertion utilizing the `RETURNING` statement. - - *Nikita Vasilevsky* - -* Use the first key in the `shards` hash from `connected_to` for the `default_shard`. - - Some applications may not want to use `:default` as a shard name in their connection model. Unfortunately Active Record expects there to be a `:default` shard because it must assume a shard to get the right connection from the pool manager. Rather than force applications to manually set this, `connects_to` can infer the default shard name from the hash of shards and will now assume that the first shard is your default. - - For example if your model looked like this: - - ```ruby - class ShardRecord < ApplicationRecord - self.abstract_class = true - - connects_to shards: { - shard_one: { writing: :shard_one }, - shard_two: { writing: :shard_two } - } - ``` - - Then the `default_shard` for this class would be set to `shard_one`. - - Fixes: #45390 - - *Eileen M. Uchitelle* - -* Fix mutation detection for serialized attributes backed by binary columns. - - *Jean Boussier* - -* Add `ActiveRecord.disconnect_all!` method to immediately close all connections from all pools. - - *Jean Boussier* - -* Discard connections which may have been left in a transaction. - - There are cases where, due to an error, `within_new_transaction` may unexpectedly leave a connection in an open transaction. In these cases the connection may be reused, and the following may occur: - - Writes appear to fail when they actually succeed. - - Writes appear to succeed when they actually fail. - - Reads return stale or uncommitted data. - - Previously, the following case was detected: - - An error is encountered during the transaction, then another error is encountered while attempting to roll it back. - - Now, the following additional cases are detected: - - An error is encountered just after successfully beginning a transaction. - - An error is encountered while committing a transaction, then another error is encountered while attempting to roll it back. - - An error is encountered while rolling back a transaction. - - *Nick Dower* - -* Active Record query cache now evicts least recently used entries - - By default it only keeps the `100` most recently used queries. - - The cache size can be configured via `database.yml` - - ```yaml - development: - adapter: mysql2 - query_cache: 200 - ``` - - It can also be entirely disabled: - - ```yaml - development: - adapter: mysql2 - query_cache: false - ``` - - *Jean Boussier* - -* Deprecate `check_pending!` in favor of `check_all_pending!`. - - `check_pending!` will only check for pending migrations on the current database connection or the one passed in. This has been deprecated in favor of `check_all_pending!` which will find all pending migrations for the database configurations in a given environment. - - *Eileen M. Uchitelle* - -* Make `increment_counter`/`decrement_counter` accept an amount argument - - ```ruby - Post.increment_counter(:comments_count, 5, by: 3) - ``` - - *fatkodima* - -* Add support for `Array#intersect?` to `ActiveRecord::Relation`. - - `Array#intersect?` is only available on Ruby 3.1 or later. - - This allows the Rubocop `Style/ArrayIntersect` cop to work with `ActiveRecord::Relation` objects. - - *John Harry Kelly* - -* The deferrable foreign key can be passed to `t.references`. - - *Hiroyuki Ishii* - -* Deprecate `deferrable: true` option of `add_foreign_key`. - - `deferrable: true` is deprecated in favor of `deferrable: :immediate`, and - will be removed in Rails 7.2. - - Because `deferrable: true` and `deferrable: :deferred` are hard to understand. - Both true and :deferred are truthy values. - This behavior is the same as the deferrable option of the add_unique_key method, added in #46192. - - *Hiroyuki Ishii* - -* `AbstractAdapter#execute` and `#exec_query` now clear the query cache - - If you need to perform a read only SQL query without clearing the query - cache, use `AbstractAdapter#select_all`. - - *Jean Boussier* - -* Make `.joins` / `.left_outer_joins` work with CTEs. - - For example: - - ```ruby - Post - .with(commented_posts: Comment.select(:post_id).distinct) - .joins(:commented_posts) - #=> WITH (...) SELECT ... INNER JOIN commented_posts on posts.id = commented_posts.post_id - ``` - - *Vladimir Dementyev* - -* Add a load hook for `ActiveRecord::ConnectionAdapters::Mysql2Adapter` - (named `active_record_mysql2adapter`) to allow for overriding aspects of the - `ActiveRecord::ConnectionAdapters::Mysql2Adapter` class. This makes `Mysql2Adapter` - consistent with `PostgreSQLAdapter` and `SQLite3Adapter` that already have load hooks. - - *fatkodima* - -* Introduce adapter for Trilogy database client - - Trilogy is a MySQL-compatible database client. Rails applications can use Trilogy - by configuring their `config/database.yml`: - - ```yaml - development: - adapter: trilogy - database: blog_development - pool: 5 - ``` - - Or by using the `DATABASE_URL` environment variable: - - ```ruby - ENV['DATABASE_URL'] # => "trilogy://localhost/blog_development?pool=5" - ``` - - *Adrianna Chang* - -* `after_commit` callbacks defined on models now execute in the correct order. - - ```ruby - class User < ActiveRecord::Base - after_commit { puts("this gets called first") } - after_commit { puts("this gets called second") } - end - ``` - - Previously, the callbacks executed in the reverse order. To opt in to the new behaviour: - - ```ruby - config.active_record.run_after_transaction_callbacks_in_order_defined = true - ``` - - This is the default for new apps. - - *Alex Ghiculescu* - -* Infer `foreign_key` when `inverse_of` is present on `has_one` and `has_many` associations. - - ```ruby - has_many :citations, foreign_key: "book1_id", inverse_of: :book - ``` - - can be simplified to - - ```ruby - has_many :citations, inverse_of: :book - ``` - - and the foreign_key will be read from the corresponding `belongs_to` association. - - *Daniel Whitney* - -* Limit max length of auto generated index names - - Auto generated index names are now limited to 62 bytes, which fits within - the default index name length limits for MySQL, Postgres and SQLite. - - Any index name over the limit will fallback to the new short format. - - Before (too long): - ``` - index_testings_on_foo_and_bar_and_first_name_and_last_name_and_administrator - ``` - - After (short format): - ``` - idx_on_foo_bar_first_name_last_name_administrator_5939248142 - ``` - - The short format includes a hash to ensure the name is unique database-wide. - - *Mike Coutermarsh* - -* Introduce a more stable and optimized Marshal serializer for Active Record models. - - Can be enabled with `config.active_record.marshalling_format_version = 7.1`. - - *Jean Boussier* - -* Allow specifying where clauses with column-tuple syntax. - - Querying through `#where` now accepts a new tuple-syntax which accepts, as - a key, an array of columns and, as a value, an array of corresponding tuples. - The key specifies a list of columns, while the value is an array of - ordered-tuples that conform to the column list. - - For instance: - - ```ruby - # Cpk::Book => Cpk::Book(author_id: integer, number: integer, title: string, revision: integer) - # Cpk::Book.primary_key => ["author_id", "number"] - - book = Cpk::Book.create!(author_id: 1, number: 1) - Cpk::Book.where(Cpk::Book.primary_key => [[1, 2]]) # => [book] - - # Topic => Topic(id: integer, title: string, author_name: string...) - - Topic.where([:title, :author_name] => [["The Alchemist", "Paulo Coelho"], ["Harry Potter", "J.K Rowling"]]) - ``` - - *Paarth Madan* - -* Allow warning codes to be ignore when reporting SQL warnings. - - Active Record config that can ignore warning codes - - ```ruby - # Configure allowlist of warnings that should always be ignored - config.active_record.db_warnings_ignore = [ - "1062", # MySQL Error 1062: Duplicate entry - ] - ``` - - This is supported for the MySQL and PostgreSQL adapters. - - *Nick Borromeo* - -* Introduce `:active_record_fixtures` lazy load hook. - - Hooks defined with this name will be run whenever `TestFixtures` is included - in a class. - - ```ruby - ActiveSupport.on_load(:active_record_fixtures) do - self.fixture_paths << "test/fixtures" - end - - klass = Class.new - klass.include(ActiveRecord::TestFixtures) - - klass.fixture_paths # => ["test/fixtures"] - ``` - - *Andrew Novoselac* - -* Introduce `TestFixtures#fixture_paths`. - - Multiple fixture paths can now be specified using the `#fixture_paths` accessor. - Apps will continue to have `test/fixtures` as their one fixture path by default, - but additional fixture paths can be specified. - - ```ruby - ActiveSupport::TestCase.fixture_paths << "component1/test/fixtures" - ActiveSupport::TestCase.fixture_paths << "component2/test/fixtures" - ``` - - `TestFixtures#fixture_path` is now deprecated. - - *Andrew Novoselac* - -* Adds support for deferrable exclude constraints in PostgreSQL. - - By default, exclude constraints in PostgreSQL are checked after each statement. - This works for most use cases, but becomes a major limitation when replacing - records with overlapping ranges by using multiple statements. - - ```ruby - exclusion_constraint :users, "daterange(valid_from, valid_to) WITH &&", deferrable: :immediate - ``` - - Passing `deferrable: :immediate` checks constraint after each statement, - but allows manually deferring the check using `SET CONSTRAINTS ALL DEFERRED` - within a transaction. This will cause the excludes to be checked after the transaction. - - It's also possible to change the default behavior from an immediate check - (after the statement), to a deferred check (after the transaction): - - ```ruby - exclusion_constraint :users, "daterange(valid_from, valid_to) WITH &&", deferrable: :deferred - ``` - - *Hiroyuki Ishii* - -* Respect `foreign_type` option to `delegated_type` for `{role}_class` method. - - Usage of `delegated_type` with non-conventional `{role}_type` column names can now be specified with `foreign_type` option. - This option is the same as `foreign_type` as forwarded to the underlying `belongs_to` association that `delegated_type` wraps. - - *Jason Karns* - -* Add support for unique constraints (PostgreSQL-only). - - ```ruby - add_unique_key :sections, [:position], deferrable: :deferred, name: "unique_section_position" - remove_unique_key :sections, name: "unique_section_position" - ``` - - See PostgreSQL's [Unique Constraints](https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-UNIQUE-CONSTRAINTS) documentation for more on unique constraints. - - By default, unique constraints in PostgreSQL are checked after each statement. - This works for most use cases, but becomes a major limitation when replacing - records with unique column by using multiple statements. - - An example of swapping unique columns between records. - - ```ruby - # position is unique column - old_item = Item.create!(position: 1) - new_item = Item.create!(position: 2) - - Item.transaction do - old_item.update!(position: 2) - new_item.update!(position: 1) - end - ``` - - Using the default behavior, the transaction would fail when executing the - first `UPDATE` statement. - - By passing the `:deferrable` option to the `add_unique_key` statement in - migrations, it's possible to defer this check. - - ```ruby - add_unique_key :items, [:position], deferrable: :immediate - ``` - - Passing `deferrable: :immediate` does not change the behaviour of the previous example, - but allows manually deferring the check using `SET CONSTRAINTS ALL DEFERRED` within a transaction. - This will cause the unique constraints to be checked after the transaction. - - It's also possible to adjust the default behavior from an immediate - check (after the statement), to a deferred check (after the transaction): - - ```ruby - add_unique_key :items, [:position], deferrable: :deferred - ``` - - If you want to change an existing unique index to deferrable, you can use :using_index - to create deferrable unique constraints. - - ```ruby - add_unique_key :items, deferrable: :deferred, using_index: "index_items_on_position" - ``` - - *Hiroyuki Ishii* - -* Remove deprecated `Tasks::DatabaseTasks.schema_file_type`. - - *Rafael Mendonça França* - -* Remove deprecated `config.active_record.partial_writes`. - - *Rafael Mendonça França* - -* Remove deprecated `ActiveRecord::Base` config accessors. - - *Rafael Mendonça França* - -* Remove the `:include_replicas` argument from `configs_for`. Use `:include_hidden` argument instead. - - *Eileen M. Uchitelle* - -* Allow applications to lookup a config via a custom hash key. - - If you have registered a custom config or want to find configs where the hash matches a specific key, now you can pass `config_key` to `configs_for`. For example if you have a `db_config` with the key `vitess` you can look up a database configuration hash by matching that key. - - ```ruby - ActiveRecord::Base.configurations.configs_for(env_name: "development", name: "primary", config_key: :vitess) - ActiveRecord::Base.configurations.configs_for(env_name: "development", config_key: :vitess) - ``` - - *Eileen M. Uchitelle* - -* Allow applications to register a custom database configuration handler. - - Adds a mechanism for registering a custom handler for cases where you want database configurations to respond to custom methods. This is useful for non-Rails database adapters or tools like Vitess that you may want to configure differently from a standard `HashConfig` or `UrlConfig`. - - Given the following database YAML we want the `animals` db to create a `CustomConfig` object instead while the `primary` database will be a `UrlConfig`: - - ```yaml - development: - primary: - url: postgres://localhost/primary - animals: - url: postgres://localhost/animals - custom_config: - sharded: 1 - ``` - - To register a custom handler first make a class that has your custom methods: - - ```ruby - class CustomConfig < ActiveRecord::DatabaseConfigurations::UrlConfig - def sharded? - custom_config.fetch("sharded", false) - end - - private - def custom_config - configuration_hash.fetch(:custom_config) - end - end - ``` - - Then register the config in an initializer: - - ```ruby - ActiveRecord::DatabaseConfigurations.register_db_config_handler do |env_name, name, url, config| - next unless config.key?(:custom_config) - CustomConfig.new(env_name, name, url, config) - end - ``` - - When the application is booted, configuration hashes with the `:custom_config` key will be `CustomConfig` objects and respond to `sharded?`. Applications must handle the condition in which Active Record should use their custom handler. - - *Eileen M. Uchitelle and John Crepezzi* - -* `ActiveRecord::Base.serialize` no longer uses YAML by default. - - YAML isn't particularly performant and can lead to security issues - if not used carefully. - - Unfortunately there isn't really any good serializers in Ruby's stdlib - to replace it. - - The obvious choice would be JSON, which is a fine format for this use case, - however the JSON serializer in Ruby's stdlib isn't strict enough, as it fallback - to casting unknown types to strings, which could lead to corrupted data. - - Some third party JSON libraries like `Oj` have a suitable strict mode. - - So it's preferable that users choose a serializer based on their own constraints. - - The original default can be restored by setting `config.active_record.default_column_serializer = YAML`. - - *Jean Boussier* - -* `ActiveRecord::Base.serialize` signature changed. - - Rather than a single positional argument that accepts two possible - types of values, `serialize` now accepts two distinct keyword arguments. - - Before: - - ```ruby - serialize :content, JSON - serialize :backtrace, Array - ``` - - After: - - ```ruby - serialize :content, coder: JSON - serialize :backtrace, type: Array - ``` - - *Jean Boussier* - -* YAML columns use `YAML.safe_dump` if available. - - As of `psych 5.1.0`, `YAML.safe_dump` can now apply the same permitted - types restrictions than `YAML.safe_load`. - - It's preferable to ensure the payload only use allowed types when we first - try to serialize it, otherwise you may end up with invalid records in the - database. - - *Jean Boussier* - -* `ActiveRecord::QueryLogs` better handle broken encoding. - - It's not uncommon when building queries with BLOB fields to contain - binary data. Unless the call carefully encode the string in ASCII-8BIT - it generally end up being encoded in `UTF-8`, and `QueryLogs` would - end up failing on it. - - `ActiveRecord::QueryLogs` no longer depend on the query to be properly encoded. - - *Jean Boussier* - -* Fix a bug where `ActiveRecord::Generators::ModelGenerator` would not respect create_table_migration template overrides. - - ``` - rails g model create_books title:string content:text - ``` - will now read from the create_table_migration.rb.tt template in the following locations in order: - ``` - lib/templates/active_record/model/create_table_migration.rb - lib/templates/active_record/migration/create_table_migration.rb - ``` - - *Spencer Neste* - -* `ActiveRecord::Relation#explain` now accepts options. - - For databases and adapters which support them (currently PostgreSQL - and MySQL), options can be passed to `explain` to provide more - detailed query plan analysis: - - ```ruby - Customer.where(id: 1).joins(:orders).explain(:analyze, :verbose) - ``` - - *Reid Lynch* - -* Multiple `Arel::Nodes::SqlLiteral` nodes can now be added together to - form `Arel::Nodes::Fragments` nodes. This allows joining several pieces - of SQL. - - *Matthew Draper*, *Ole Friis* - -* `ActiveRecord::Base#signed_id` raises if called on a new record. - - Previously it would return an ID that was not usable, since it was based on `id = nil`. - - *Alex Ghiculescu* - -* Allow SQL warnings to be reported. - - Active Record configs can be set to enable SQL warning reporting. - - ```ruby - # Configure action to take when SQL query produces warning - config.active_record.db_warnings_action = :raise - - # Configure allowlist of warnings that should always be ignored - config.active_record.db_warnings_ignore = [ - /Invalid utf8mb4 character string/, - "An exact warning message", - ] - ``` - - This is supported for the MySQL and PostgreSQL adapters. - - *Adrianna Chang*, *Paarth Madan* - -* Add `#regroup` query method as a short-hand for `.unscope(:group).group(fields)` - - Example: - - ```ruby - Post.group(:title).regroup(:author) - # SELECT `posts`.`*` FROM `posts` GROUP BY `posts`.`author` - ``` - - *Danielius Visockas* - -* PostgreSQL adapter method `enable_extension` now allows parameter to be `[schema_name.]` - if the extension must be installed on another schema. - - Example: `enable_extension('heroku_ext.hstore')` - - *Leonardo Luarte* - -* Add `:include` option to `add_index`. - - Add support for including non-key columns in indexes for PostgreSQL - with the `INCLUDE` parameter. - - ```ruby - add_index(:users, :email, include: [:id, :created_at]) - ``` - - will result in: - - ```sql - CREATE INDEX index_users_on_email USING btree (email) INCLUDE (id, created_at) - ``` - - *Steve Abrams* - -* `ActiveRecord::Relation`’s `#any?`, `#none?`, and `#one?` methods take an optional pattern - argument, more closely matching their `Enumerable` equivalents. - - *George Claghorn* - -* Add `ActiveRecord::Base.normalizes` for declaring attribute normalizations. - - An attribute normalization is applied when the attribute is assigned or - updated, and the normalized value will be persisted to the database. The - normalization is also applied to the corresponding keyword argument of query - methods, allowing records to be queried using unnormalized values. - - For example: - - ```ruby - class User < ActiveRecord::Base - normalizes :email, with: -> email { email.strip.downcase } - normalizes :phone, with: -> phone { phone.delete("^0-9").delete_prefix("1") } - end - - user = User.create(email: " CRUISE-CONTROL@EXAMPLE.COM\n") - user.email # => "cruise-control@example.com" - - user = User.find_by(email: "\tCRUISE-CONTROL@EXAMPLE.COM ") - user.email # => "cruise-control@example.com" - user.email_before_type_cast # => "cruise-control@example.com" - - User.where(email: "\tCRUISE-CONTROL@EXAMPLE.COM ").count # => 1 - User.where(["email = ?", "\tCRUISE-CONTROL@EXAMPLE.COM "]).count # => 0 - - User.exists?(email: "\tCRUISE-CONTROL@EXAMPLE.COM ") # => true - User.exists?(["email = ?", "\tCRUISE-CONTROL@EXAMPLE.COM "]) # => false - - User.normalize_value_for(:phone, "+1 (555) 867-5309") # => "5558675309" - ``` - - *Jonathan Hefner* - -* Hide changes to before_committed! callback behaviour behind flag. - - In #46525, behavior around before_committed! callbacks was changed so that callbacks - would run on every enrolled record in a transaction, not just the first copy of a record. - This change in behavior is now controlled by a configuration option, - `config.active_record.before_committed_on_all_records`. It will be enabled by default on Rails 7.1. - - *Adrianna Chang* - -* The `namespaced_controller` Query Log tag now matches the `controller` format - - For example, a request processed by `NameSpaced::UsersController` will now log as: - - ``` - :controller # "users" - :namespaced_controller # "name_spaced/users" - ``` - - *Alex Ghiculescu* - -* Return only unique ids from ActiveRecord::Calculations#ids - - Updated ActiveRecord::Calculations#ids to only return the unique ids of the base model - when using eager_load, preload and includes. - - ```ruby - Post.find_by(id: 1).comments.count - # => 5 - Post.includes(:comments).where(id: 1).pluck(:id) - # => [1, 1, 1, 1, 1] - Post.includes(:comments).where(id: 1).ids - # => [1] - ``` - - *Joshua Young* - -* Stop using `LOWER()` for case-insensitive queries on `citext` columns - - Previously, `LOWER()` was added for e.g. uniqueness validations with - `case_sensitive: false`. - It wasn't mentioned in the documentation that the index without `LOWER()` - wouldn't be used in this case. - - *Phil Pirozhkov* - -* Extract `#sync_timezone_changes` method in AbstractMysqlAdapter to enable subclasses - to sync database timezone changes without overriding `#raw_execute`. - - *Adrianna Chang*, *Paarth Madan* - -* Do not write additional new lines when dumping sql migration versions - - This change updates the `insert_versions_sql` function so that the database insert string containing the current database migration versions does not end with two additional new lines. - - *Misha Schwartz* - -* Fix `composed_of` value freezing and duplication. - - Previously composite values exhibited two confusing behaviors: - - - When reading a compositve value it'd _NOT_ be frozen, allowing it to get out of sync with its underlying database - columns. - - When writing a compositve value the argument would be frozen, potentially confusing the caller. - - Currently, composite values instantiated based on database columns are frozen (addressing the first issue) and - assigned compositve values are duplicated and the duplicate is frozen (addressing the second issue). - - *Greg Navis* - -* Fix redundant updates to the column insensitivity cache - - Fixed redundant queries checking column capability for insensitive - comparison. - - *Phil Pirozhkov* - -* Allow disabling methods generated by `ActiveRecord.enum`. - - *Alfred Dominic* - -* Avoid validating `belongs_to` association if it has not changed. - - Previously, when updating a record, Active Record will perform an extra query to check for the presence of - `belongs_to` associations (if the presence is configured to be mandatory), even if that attribute hasn't changed. - - Currently, only `belongs_to`-related columns are checked for presence. It is possible to have orphaned records with - this approach. To avoid this problem, you need to use a foreign key. - - This behavior can be controlled by configuration: - - ```ruby - config.active_record.belongs_to_required_validates_foreign_key = false - ``` - - and will be disabled by default with `config.load_defaults 7.1`. - - *fatkodima* - -* `has_one` and `belongs_to` associations now define a `reset_association` method - on the owner model (where `association` is the name of the association). This - method unloads the cached associate record, if any, and causes the next access - to query it from the database. - - *George Claghorn* - -* Allow per attribute setting of YAML permitted classes (safe load) and unsafe load. - - *Carlos Palhares* - -* Add a build persistence method - - Provides a wrapper for `new`, to provide feature parity with `create`s - ability to create multiple records from an array of hashes, using the - same notation as the `build` method on associations. - - *Sean Denny* - -* Raise on assignment to readonly attributes - - ```ruby - class Post < ActiveRecord::Base - attr_readonly :content - end - Post.create!(content: "cannot be updated") - post.content # "cannot be updated" - post.content = "something else" # => ActiveRecord::ReadonlyAttributeError - ``` - - Previously, assignment would succeed but silently not write to the database. - - This behavior can be controlled by configuration: - - ```ruby - config.active_record.raise_on_assign_to_attr_readonly = true - ``` - - and will be enabled by default with `config.load_defaults 7.1`. - - *Alex Ghiculescu*, *Hartley McGuire* - -* Allow unscoping of preload and eager_load associations - - Added the ability to unscope preload and eager_load associations just like - includes, joins, etc. See ActiveRecord::QueryMethods::VALID_UNSCOPING_VALUES - for the full list of supported unscopable scopes. - - ```ruby - query.unscope(:eager_load, :preload).group(:id).select(:id) - ``` - - *David Morehouse* - -* Add automatic filtering of encrypted attributes on inspect - - This feature is enabled by default but can be disabled with - - ```ruby - config.active_record.encryption.add_to_filter_parameters = false - ``` - - *Hartley McGuire* - -* Clear locking column on #dup - - This change fixes not to duplicate locking_column like id and timestamps. - - ``` - car = Car.create! - car.touch - car.lock_version #=> 1 - car.dup.lock_version #=> 0 - ``` - - *Shouichi Kamiya*, *Seonggi Yang*, *Ryohei UEDA* - -* Invalidate transaction as early as possible - - After rescuing a `TransactionRollbackError` exception Rails invalidates transactions earlier in the flow - allowing the framework to skip issuing the `ROLLBACK` statement in more cases. - Only affects adapters that have `savepoint_errors_invalidate_transactions?` configured as `true`, - which at this point is only applicable to the `mysql2` adapter. - - *Nikita Vasilevsky* - -* Allow configuring columns list to be used in SQL queries issued by an `ActiveRecord::Base` object - - It is now possible to configure columns list that will be used to build an SQL query clauses when - updating, deleting or reloading an `ActiveRecord::Base` object - - ```ruby - class Developer < ActiveRecord::Base - query_constraints :company_id, :id - end - developer = Developer.first.update(name: "Bob") - # => UPDATE "developers" SET "name" = 'Bob' WHERE "developers"."company_id" = 1 AND "developers"."id" = 1 - ``` - - *Nikita Vasilevsky* - -* Adds `validate` to foreign keys and check constraints in schema.rb - - Previously, `schema.rb` would not record if `validate: false` had been used when adding a foreign key or check - constraint, so restoring a database from the schema could result in foreign keys or check constraints being - incorrectly validated. - - *Tommy Graves* - -* Adapter `#execute` methods now accept an `allow_retry` option. When set to `true`, the SQL statement will be - retried, up to the database's configured `connection_retries` value, upon encountering connection-related errors. - - *Adrianna Chang* - -* Only trigger `after_commit :destroy` callbacks when a database row is deleted. - - This prevents `after_commit :destroy` callbacks from being triggered again - when `destroy` is called multiple times on the same record. - - *Ben Sheldon* - -* Fix `ciphertext_for` for yet-to-be-encrypted values. - - Previously, `ciphertext_for` returned the cleartext of values that had not - yet been encrypted, such as with an unpersisted record: - - ```ruby - Post.encrypts :body - - post = Post.create!(body: "Hello") - post.ciphertext_for(:body) - # => "{\"p\":\"abc..." - - post.body = "World" - post.ciphertext_for(:body) - # => "World" - ``` - - Now, `ciphertext_for` will always return the ciphertext of encrypted - attributes: - - ```ruby - Post.encrypts :body - - post = Post.create!(body: "Hello") - post.ciphertext_for(:body) - # => "{\"p\":\"abc..." - - post.body = "World" - post.ciphertext_for(:body) - # => "{\"p\":\"xyz..." - ``` - - *Jonathan Hefner* - -* Fix a bug where using groups and counts with long table names would return incorrect results. - - *Shota Toguchi*, *Yusaku Ono* - -* Fix encryption of column default values. - - Previously, encrypted attributes that used column default values appeared to - be encrypted on create, but were not: - - ```ruby - Book.encrypts :name - - book = Book.create! - book.name - # => "" - book.name_before_type_cast - # => "{\"p\":\"abc..." - book.reload.name_before_type_cast - # => "" - ``` - - Now, attributes with column default values are encrypted: - - ```ruby - Book.encrypts :name - - book = Book.create! - book.name - # => "" - book.name_before_type_cast - # => "{\"p\":\"abc..." - book.reload.name_before_type_cast - # => "{\"p\":\"abc..." - ``` - - *Jonathan Hefner* - -* Deprecate delegation from `Base` to `connection_handler`. - - Calling `Base.clear_all_connections!`, `Base.clear_active_connections!`, `Base.clear_reloadable_connections!` and `Base.flush_idle_connections!` is deprecated. Please call these methods on the connection handler directly. In future Rails versions, the delegation from `Base` to the `connection_handler` will be removed. - - *Eileen M. Uchitelle* - -* Allow ActiveRecord::QueryMethods#reselect to receive hash values, similar to ActiveRecord::QueryMethods#select - - *Sampat Badhe* - -* Validate options when managing columns and tables in migrations. - - If an invalid option is passed to a migration method like `create_table` and `add_column`, an error will be raised - instead of the option being silently ignored. Validation of the options will only be applied for new migrations - that are created. - - *Guo Xiang Tan*, *George Wambold* - -* Update query log tags to use the [SQLCommenter](https://open-telemetry.github.io/opentelemetry-sqlcommenter/) format by default. See [#46179](https://github.com/rails/rails/issues/46179) - - To opt out of SQLCommenter-formatted query log tags, set `config.active_record.query_log_tags_format = :legacy`. By default, this is set to `:sqlcommenter`. - - *Modulitos* and *Iheanyi* - -* Allow any ERB in the database.yml when creating rake tasks. - - Any ERB can be used in `database.yml` even if it accesses environment - configurations. - - Deprecates `config.active_record.suppress_multiple_database_warning`. - - *Eike Send* - -* Add table to error for duplicate column definitions. - - If a migration defines duplicate columns for a table, the error message - shows which table it concerns. - - *Petrik de Heus* - -* Fix erroneous nil default precision on virtual datetime columns. - - Prior to this change, virtual datetime columns did not have the same - default precision as regular datetime columns, resulting in the following - being erroneously equivalent: - - t.virtual :name, type: datetime, as: "expression" - t.virtual :name, type: datetime, precision: nil, as: "expression" - - This change fixes the default precision lookup, so virtual and regular - datetime column default precisions match. - - *Sam Bostock* - -* Use connection from `#with_raw_connection` in `#quote_string`. - - This ensures that the string quoting is wrapped in the reconnect and retry logic - that `#with_raw_connection` offers. - - *Adrianna Chang* - -* Add `expires_at` option to `signed_id`. - - *Shouichi Kamiya* - -* Allow applications to set retry deadline for query retries. - - Building on the work done in #44576 and #44591, we extend the logic that automatically - reconnects database connections to take into account a timeout limit. We won't retry - a query if a given amount of time has elapsed since the query was first attempted. This - value defaults to nil, meaning that all retryable queries are retried regardless of time elapsed, - but this can be changed via the `retry_deadline` option in the database config. - - *Adrianna Chang* - -* Fix a case where the query cache can return wrong values. See #46044 - - *Aaron Patterson* - -* Support MySQL's ssl-mode option for MySQLDatabaseTasks. - - Verifying the identity of the database server requires setting the ssl-mode - option to VERIFY_CA or VERIFY_IDENTITY. This option was previously ignored - for MySQL database tasks like creating a database and dumping the structure. - - *Petrik de Heus* - -* Move `ActiveRecord::InternalMetadata` to an independent object. - - `ActiveRecord::InternalMetadata` no longer inherits from `ActiveRecord::Base` and is now an independent object that should be instantiated with a `connection`. This class is private and should not be used by applications directly. If you want to interact with the schema migrations table, please access it on the connection directly, for example: `ActiveRecord::Base.connection.schema_migration`. - - *Eileen M. Uchitelle* - -* Deprecate quoting `ActiveSupport::Duration` as an integer - - Using ActiveSupport::Duration as an interpolated bind parameter in a SQL - string template is deprecated. To avoid this warning, you should explicitly - convert the duration to a more specific database type. For example, if you - want to use a duration as an integer number of seconds: - ``` - Record.where("duration = ?", 1.hour.to_i) - ``` - If you want to use a duration as an ISO 8601 string: - ``` - Record.where("duration = ?", 1.hour.iso8601) - ``` - - *Aram Greenman* - -* Allow `QueryMethods#in_order_of` to order by a string column name. - - ```ruby - Post.in_order_of("id", [4,2,3,1]).to_a - Post.joins(:author).in_order_of("authors.name", ["Bob", "Anna", "John"]).to_a - ``` - - *Igor Kasyanchuk* - -* Move `ActiveRecord::SchemaMigration` to an independent object. - - `ActiveRecord::SchemaMigration` no longer inherits from `ActiveRecord::Base` and is now an independent object that should be instantiated with a `connection`. This class is private and should not be used by applications directly. If you want to interact with the schema migrations table, please access it on the connection directly, for example: `ActiveRecord::Base.connection.schema_migration`. - - *Eileen M. Uchitelle* - -* Deprecate `all_connection_pools` and make `connection_pool_list` more explicit. - - Following on #45924 `all_connection_pools` is now deprecated. `connection_pool_list` will either take an explicit role or applications can opt into the new behavior by passing `:all`. - - *Eileen M. Uchitelle* - -* Fix connection handler methods to operate on all pools. - - `active_connections?`, `clear_active_connections!`, `clear_reloadable_connections!`, `clear_all_connections!`, and `flush_idle_connections!` now operate on all pools by default. Previously they would default to using the `current_role` or `:writing` role unless specified. - - *Eileen M. Uchitelle* - - -* Allow ActiveRecord::QueryMethods#select to receive hash values. - - Currently, `select` might receive only raw sql and symbols to define columns and aliases to select. - - With this change we can provide `hash` as argument, for example: - - ```ruby - Post.joins(:comments).select(posts: [:id, :title, :created_at], comments: [:id, :body, :author_id]) - #=> "SELECT \"posts\".\"id\", \"posts\".\"title\", \"posts\".\"created_at\", \"comments\".\"id\", \"comments\".\"body\", \"comments\".\"author_id\" - # FROM \"posts\" INNER JOIN \"comments\" ON \"comments\".\"post_id\" = \"posts\".\"id\"" - - Post.joins(:comments).select(posts: { id: :post_id, title: :post_title }, comments: { id: :comment_id, body: :comment_body }) - #=> "SELECT posts.id as post_id, posts.title as post_title, comments.id as comment_id, comments.body as comment_body - # FROM \"posts\" INNER JOIN \"comments\" ON \"comments\".\"post_id\" = \"posts\".\"id\"" - ``` - *Oleksandr Holubenko*, *Josef Šimánek*, *Jean Boussier* - -* Adapts virtual attributes on `ActiveRecord::Persistence#becomes`. - - When source and target classes have a different set of attributes adapts - attributes such that the extra attributes from target are added. - - ```ruby - class Person < ApplicationRecord - end - - class WebUser < Person - attribute :is_admin, :boolean - after_initialize :set_admin - - def set_admin - write_attribute(:is_admin, email =~ /@ourcompany\.com$/) - end - end - - person = Person.find_by(email: "email@ourcompany.com") - person.respond_to? :is_admin - # => false - person.becomes(WebUser).is_admin? - # => true - ``` - - *Jacopo Beschi*, *Sampson Crowley* - -* Fix `ActiveRecord::QueryMethods#in_order_of` to include `nil`s, to match the - behavior of `Enumerable#in_order_of`. - - For example, `Post.in_order_of(:title, [nil, "foo"])` will now include posts - with `nil` titles, the same as `Post.all.to_a.in_order_of(:title, [nil, "foo"])`. - - *fatkodima* - -* Optimize `add_timestamps` to use a single SQL statement. - - ```ruby - add_timestamps :my_table - ``` - - Now results in the following SQL: - - ```sql - ALTER TABLE "my_table" ADD COLUMN "created_at" datetime(6) NOT NULL, ADD COLUMN "updated_at" datetime(6) NOT NULL - ``` - - *Iliana Hadzhiatanasova* - -* Add `drop_enum` migration command for PostgreSQL - - This does the inverse of `create_enum`. Before dropping an enum, ensure you have - dropped columns that depend on it. - - *Alex Ghiculescu* - -* Adds support for `if_exists` option when removing a check constraint. - - The `remove_check_constraint` method now accepts an `if_exists` option. If set - to true an error won't be raised if the check constraint doesn't exist. - - *Margaret Parsa* and *Aditya Bhutani* - -* `find_or_create_by` now try to find a second time if it hits a unicity constraint. - - `find_or_create_by` always has been inherently racy, either creating multiple - duplicate records or failing with `ActiveRecord::RecordNotUnique` depending on - whether a proper unicity constraint was set. - - `create_or_find_by` was introduced for this use case, however it's quite wasteful - when the record is expected to exist most of the time, as INSERT require to send - more data than SELECT and require more work from the database. Also on some - databases it can actually consume a primary key increment which is undesirable. - - So for case where most of the time the record is expected to exist, `find_or_create_by` - can be made race-condition free by re-trying the `find` if the `create` failed - with `ActiveRecord::RecordNotUnique`. This assumes that the table has the proper - unicity constraints, if not, `find_or_create_by` will still lead to duplicated records. - - *Jean Boussier*, *Alex Kitchens* - -* Introduce a simpler constructor API for ActiveRecord database adapters. - - Previously the adapter had to know how to build a new raw connection to - support reconnect, but also expected to be passed an initial already- - established connection. - - When manually creating an adapter instance, it will now accept a single - config hash, and only establish the real connection on demand. - - *Matthew Draper* - -* Avoid redundant `SELECT 1` connection-validation query during DB pool - checkout when possible. - - If the first query run during a request is known to be idempotent, it can be - used directly to validate the connection, saving a network round-trip. - - *Matthew Draper* - -* Automatically reconnect broken database connections when safe, even - mid-request. - - When an error occurs while attempting to run a known-idempotent query, and - not inside a transaction, it is safe to immediately reconnect to the - database server and try again, so this is now the default behavior. - - This new default should always be safe -- to support that, it's consciously - conservative about which queries are considered idempotent -- but if - necessary it can be disabled by setting the `connection_retries` connection - option to `0`. - - *Matthew Draper* - -* Avoid removing a PostgreSQL extension when there are dependent objects. - - Previously, removing an extension also implicitly removed dependent objects. Now, this will raise an error. - - You can force removing the extension: - - ```ruby - disable_extension :citext, force: :cascade - ``` - - Fixes #29091. - - *fatkodima* - -* Allow nested functions as safe SQL string - - *Michael Siegfried* - -* Allow `destroy_association_async_job=` to be configured with a class string instead of a constant. - - Defers an autoloading dependency between `ActiveRecord::Base` and `ActiveJob::Base` - and moves the configuration of `ActiveRecord::DestroyAssociationAsyncJob` - from ActiveJob to ActiveRecord. - - Deprecates `ActiveRecord::ActiveJobRequiredError` and now raises a `NameError` - if the job class is unloadable or an `ActiveRecord::ConfigurationError` if - `dependent: :destroy_async` is declared on an association but there is no job - class configured. - - *Ben Sheldon* - -* Fix `ActiveRecord::Store` to serialize as a regular Hash - - Previously it would serialize as an `ActiveSupport::HashWithIndifferentAccess` - which is wasteful and cause problem with YAML safe_load. - - *Jean Boussier* - -* Add `timestamptz` as a time zone aware type for PostgreSQL - - This is required for correctly parsing `timestamp with time zone` values in your database. - - If you don't want this, you can opt out by adding this initializer: - - ```ruby - ActiveRecord::Base.time_zone_aware_types -= [:timestamptz] - ``` - - *Alex Ghiculescu* - -* Add new `ActiveRecord::Base.generates_token_for` API. - - Currently, `signed_id` fulfills the role of generating tokens for e.g. - resetting a password. However, signed IDs cannot reflect record state, so - if a token is intended to be single-use, it must be tracked in a database at - least until it expires. - - With `generates_token_for`, a token can embed data from a record. When - using the token to fetch the record, the data from the token and the current - data from the record will be compared. If the two do not match, the token - will be treated as invalid, the same as if it had expired. For example: - - ```ruby - class User < ActiveRecord::Base - has_secure_password - - generates_token_for :password_reset, expires_in: 15.minutes do - # A password's BCrypt salt changes when the password is updated. - # By embedding (part of) the salt in a token, the token will - # expire when the password is updated. - BCrypt::Password.new(password_digest).salt[-10..] - end - end - - user = User.first - token = user.generate_token_for(:password_reset) - - User.find_by_token_for(:password_reset, token) # => user - - user.update!(password: "new password") - User.find_by_token_for(:password_reset, token) # => nil - ``` - - *Jonathan Hefner* - -* Optimize Active Record batching for whole table iterations. - - Previously, `in_batches` got all the ids and constructed an `IN`-based query for each batch. - When iterating over the whole tables, this approach is not optimal as it loads unneeded ids and - `IN` queries with lots of items are slow. - - Now, whole table iterations use range iteration (`id >= x AND id <= y`) by default which can make iteration - several times faster. E.g., tested on a PostgreSQL table with 10 million records: querying (`253s` vs `30s`), - updating (`288s` vs `124s`), deleting (`268s` vs `83s`). - - Only whole table iterations use this style of iteration by default. You can disable this behavior by passing `use_ranges: false`. - If you iterate over the table and the only condition is, e.g., `archived_at: nil` (and only a tiny fraction - of the records are archived), it makes sense to opt in to this approach: - - ```ruby - Project.where(archived_at: nil).in_batches(use_ranges: true) do |relation| - # do something - end - ``` - - See #45414 for more details. - - *fatkodima* - -* `.with` query method added. Construct common table expressions with ease and get `ActiveRecord::Relation` back. - - ```ruby - Post.with(posts_with_comments: Post.where("comments_count > ?", 0)) - # => ActiveRecord::Relation - # WITH posts_with_comments AS (SELECT * FROM posts WHERE (comments_count > 0)) SELECT * FROM posts - ``` - - *Vlado Cingel* - -* Don't establish a new connection if an identical pool exists already. - - Previously, if `establish_connection` was called on a class that already had an established connection, the existing connection would be removed regardless of whether it was the same config. Now if a pool is found with the same values as the new connection, the existing connection will be returned instead of creating a new one. - - This has a slight change in behavior if application code is depending on a new connection being established regardless of whether it's identical to an existing connection. If the old behavior is desirable, applications should call `ActiveRecord::Base#remove_connection` before establishing a new one. Calling `establish_connection` with a different config works the same way as it did previously. - - *Eileen M. Uchitelle* - -* Update `db:prepare` task to load schema when an uninitialized database exists, and dump schema after migrations. - - *Ben Sheldon* - -* Fix supporting timezone awareness for `tsrange` and `tstzrange` array columns. - - ```ruby - # In database migrations - add_column :shops, :open_hours, :tsrange, array: true - # In app config - ActiveRecord::Base.time_zone_aware_types += [:tsrange] - # In the code times are properly converted to app time zone - Shop.create!(open_hours: [Time.current..8.hour.from_now]) - ``` - - *Wojciech Wnętrzak* - -* Introduce strategy pattern for executing migrations. - - By default, migrations will use a strategy object that delegates the method - to the connection adapter. Consumers can implement custom strategy objects - to change how their migrations run. - - *Adrianna Chang* - -* Add adapter option disallowing foreign keys - - This adds a new option to be added to `database.yml` which enables skipping - foreign key constraints usage even if the underlying database supports them. - - Usage: - ```yaml - development: - <<: *default - database: storage/development.sqlite3 - foreign_keys: false - ``` - - *Paulo Barros* - -* Add configurable deprecation warning for singular associations - - This adds a deprecation warning when using the plural name of a singular associations in `where`. - It is possible to opt into the new more performant behavior with `config.active_record.allow_deprecated_singular_associations_name = false` - - *Adam Hess* - -* Run transactional callbacks on the freshest instance to save a given - record within a transaction. - - When multiple Active Record instances change the same record within a - transaction, Rails runs `after_commit` or `after_rollback` callbacks for - only one of them. `config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction` - was added to specify how Rails chooses which instance receives the - callbacks. The framework defaults were changed to use the new logic. - - When `config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction` - is `true`, transactional callbacks are run on the first instance to save, - even though its instance state may be stale. - - When it is `false`, which is the new framework default starting with version - 7.1, transactional callbacks are run on the instances with the freshest - instance state. Those instances are chosen as follows: - - - In general, run transactional callbacks on the last instance to save a - given record within the transaction. - - There are two exceptions: - - If the record is created within the transaction, then updated by - another instance, `after_create_commit` callbacks will be run on the - second instance. This is instead of the `after_update_commit` - callbacks that would naively be run based on that instance’s state. - - If the record is destroyed within the transaction, then - `after_destroy_commit` callbacks will be fired on the last destroyed - instance, even if a stale instance subsequently performed an update - (which will have affected 0 rows). - - *Cameron Bothner and Mitch Vollebregt* - -* Enable strict strings mode for `SQLite3Adapter`. - - Configures SQLite with a strict strings mode, which disables double-quoted string literals. - - SQLite has some quirks around double-quoted string literals. - It first tries to consider double-quoted strings as identifier names, but if they don't exist - it then considers them as string literals. Because of this, typos can silently go unnoticed. - For example, it is possible to create an index for a non existing column. - See [SQLite documentation](https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted) for more details. - - If you don't want this behavior, you can disable it via: - - ```ruby - # config/application.rb - config.active_record.sqlite3_adapter_strict_strings_by_default = false - ``` - - Fixes #27782. - - *fatkodima*, *Jean Boussier* - -* Resolve issue where a relation cache_version could be left stale. - - Previously, when `reset` was called on a relation object it did not reset the cache_versions - ivar. This led to a confusing situation where despite having the correct data the relation - still reported a stale cache_version. - - Usage: - - ```ruby - developers = Developer.all - developers.cache_version - - Developer.update_all(updated_at: Time.now.utc + 1.second) - - developers.cache_version # Stale cache_version - developers.reset - developers.cache_version # Returns the current correct cache_version - ``` - - Fixes #45341. - - *Austen Madden* - -* Add support for exclusion constraints (PostgreSQL-only). - - ```ruby - add_exclusion_constraint :invoices, "daterange(start_date, end_date) WITH &&", using: :gist, name: "invoices_date_overlap" - remove_exclusion_constraint :invoices, name: "invoices_date_overlap" - ``` - - See PostgreSQL's [`CREATE TABLE ... EXCLUDE ...`](https://www.postgresql.org/docs/12/sql-createtable.html#SQL-CREATETABLE-EXCLUDE) documentation for more on exclusion constraints. - - *Alex Robbin* - -* `change_column_null` raises if a non-boolean argument is provided - - Previously if you provided a non-boolean argument, `change_column_null` would - treat it as truthy and make your column nullable. This could be surprising, so now - the input must be either `true` or `false`. - - ```ruby - change_column_null :table, :column, true # good - change_column_null :table, :column, false # good - change_column_null :table, :column, from: true, to: false # raises (previously this made the column nullable) - ``` - - *Alex Ghiculescu* - -* Enforce limit on table names length. - - Fixes #45130. - - *fatkodima* - -* Adjust the minimum MariaDB version for check constraints support. - - *Eddie Lebow* - -* Fix Hstore deserialize regression. - - *edsharp* - -* Add validity for PostgreSQL indexes. - - ```ruby - connection.index_exists?(:users, :email, valid: true) - connection.indexes(:users).select(&:valid?) - ``` - - *fatkodima* - -* Fix eager loading for models without primary keys. - - *Anmol Chopra*, *Matt Lawrence*, and *Jonathan Hefner* - -* Avoid validating a unique field if it has not changed and is backed by a unique index. - - Previously, when saving a record, Active Record will perform an extra query to check for the - uniqueness of each attribute having a `uniqueness` validation, even if that attribute hasn't changed. - If the database has the corresponding unique index, then this validation can never fail for persisted - records, and we could safely skip it. - - *fatkodima* - -* Stop setting `sql_auto_is_null` - - Since version 5.5 the default has been off, we no longer have to manually turn it off. - - *Adam Hess* - -* Fix `touch` to raise an error for readonly columns. - - *fatkodima* - -* Add ability to ignore tables by regexp for SQL schema dumps. - - ```ruby - ActiveRecord::SchemaDumper.ignore_tables = [/^_/] - ``` - - *fatkodima* - -* Avoid queries when performing calculations on contradictory relations. - - Previously calculations would make a query even when passed a - contradiction, such as `User.where(id: []).count`. We no longer perform a - query in that scenario. - - This applies to the following calculations: `count`, `sum`, `average`, - `minimum` and `maximum` - - *Luan Vieira, John Hawthorn and Daniel Colson* - -* Allow using aliased attributes with `insert_all`/`upsert_all`. - - ```ruby - class Book < ApplicationRecord - alias_attribute :title, :name - end - - Book.insert_all [{ title: "Remote", author_id: 1 }], returning: :title - ``` - - *fatkodima* - -* Support encrypted attributes on columns with default db values. - - This adds support for encrypted attributes defined on columns with default values. - It will encrypt those values at creation time. Before, it would raise an - error unless `config.active_record.encryption.support_unencrypted_data` was true. - - *Jorge Manrubia* and *Dima Fatko* - -* Allow overriding `reading_request?` in `DatabaseSelector::Resolver` - - The default implementation checks if a request is a `get?` or `head?`, - but you can now change it to anything you like. If the method returns true, - `Resolver#read` gets called meaning the request could be served by the - replica database. - - *Alex Ghiculescu* - -* Remove `ActiveRecord.legacy_connection_handling`. - - *Eileen M. Uchitelle* - -* `rails db:schema:{dump,load}` now checks `ENV["SCHEMA_FORMAT"]` before config - - Since `rails db:structure:{dump,load}` was deprecated there wasn't a simple - way to dump a schema to both SQL and Ruby formats. You can now do this with - an environment variable. For example: - - ``` - SCHEMA_FORMAT=sql rake db:schema:dump - ``` - - *Alex Ghiculescu* - -* Fixed MariaDB default function support. - - Defaults would be written wrong in "db/schema.rb" and not work correctly - if using `db:schema:load`. Further more the function name would be - added as string content when saving new records. - - *kaspernj* - -* Add `active_record.destroy_association_async_batch_size` configuration - - This allows applications to specify the maximum number of records that will - be destroyed in a single background job by the `dependent: :destroy_async` - association option. By default, the current behavior will remain the same: - when a parent record is destroyed, all dependent records will be destroyed - in a single background job. If the number of dependent records is greater - than this configuration, the records will be destroyed in multiple - background jobs. - - *Nick Holden* - -* Fix `remove_foreign_key` with `:if_exists` option when foreign key actually exists. - - *fatkodima* - -* Remove `--no-comments` flag in structure dumps for PostgreSQL - - This broke some apps that used custom schema comments. If you don't want - comments in your structure dump, you can use: - - ```ruby - ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = ['--no-comments'] - ``` - - *Alex Ghiculescu* - -* Reduce the memory footprint of fixtures accessors. - - Until now fixtures accessors were eagerly defined using `define_method`. - So the memory usage was directly dependent of the number of fixtures and - test suites. - - Instead fixtures accessors are now implemented with `method_missing`, - so they incur much less memory and CPU overhead. - - *Jean Boussier* - -* Fix `config.active_record.destroy_association_async_job` configuration - - `config.active_record.destroy_association_async_job` should allow - applications to specify the job that will be used to destroy associated - records in the background for `has_many` associations with the - `dependent: :destroy_async` option. Previously, that was ignored, which - meant the default `ActiveRecord::DestroyAssociationAsyncJob` always - destroyed records in the background. - - *Nick Holden* - -* Fix `change_column_comment` to preserve column's AUTO_INCREMENT in the MySQL adapter - - *fatkodima* - -* Fix quoting of `ActiveSupport::Duration` and `Rational` numbers in the MySQL adapter. - - *Kevin McPhillips* - -* Allow column name with COLLATE (e.g., title COLLATE "C") as safe SQL string - - *Shugo Maeda* - -* Permit underscores in the VERSION argument to database rake tasks. - - *Eddie Lebow* - -* Reversed the order of `INSERT` statements in `structure.sql` dumps - - This should decrease the likelihood of merge conflicts. New migrations - will now be added at the top of the list. - - For existing apps, there will be a large diff the next time `structure.sql` - is generated. - - *Alex Ghiculescu*, *Matt Larraz* - -* Fix PG.connect keyword arguments deprecation warning on ruby 2.7 - - Fixes #44307. - - *Nikita Vasilevsky* - -* Fix dropping DB connections after serialization failures and deadlocks. - - Prior to 6.1.4, serialization failures and deadlocks caused rollbacks to be - issued for both real transactions and savepoints. This breaks MySQL which - disallows rollbacks of savepoints following a deadlock. - - 6.1.4 removed these rollbacks, for both transactions and savepoints, causing - the DB connection to be left in an unknown state and thus discarded. - - These rollbacks are now restored, except for savepoints on MySQL. - - *Thomas Morgan* - -* Make `ActiveRecord::ConnectionPool` Fiber-safe - - When `ActiveSupport::IsolatedExecutionState.isolation_level` is set to `:fiber`, - the connection pool now supports multiple Fibers from the same Thread checking - out connections from the pool. - - *Alex Matchneer* - -* Add `update_attribute!` to `ActiveRecord::Persistence` - - Similar to `update_attribute`, but raises `ActiveRecord::RecordNotSaved` when a `before_*` callback throws `:abort`. - - ```ruby - class Topic < ActiveRecord::Base - before_save :check_title - - def check_title - throw(:abort) if title == "abort" - end - end - - topic = Topic.create(title: "Test Title") - # #=> # - topic.update_attribute!(:title, "Another Title") - # #=> # - topic.update_attribute!(:title, "abort") - # raises ActiveRecord::RecordNotSaved - ``` - - *Drew Tempelmeyer* - -* Avoid loading every record in `ActiveRecord::Relation#pretty_print` - - ```ruby - # Before - pp Foo.all # Loads the whole table. - - # After - pp Foo.all # Shows 10 items and an ellipsis. - ``` - - *Ulysse Buonomo* - -* Change `QueryMethods#in_order_of` to drop records not listed in values. - - `in_order_of` now filters down to the values provided, to match the behavior of the `Enumerable` version. - - *Kevin Newton* - -* Allow named expression indexes to be revertible. - - Previously, the following code would raise an error in a reversible migration executed while rolling back, due to the index name not being used in the index removal. - - ```ruby - add_index(:settings, "(data->'property')", using: :gin, name: :index_settings_data_property) - ``` - - Fixes #43331. - - *Oliver Günther* - -* Fix incorrect argument in PostgreSQL structure dump tasks. - - Updating the `--no-comment` argument added in Rails 7 to the correct `--no-comments` argument. - - *Alex Dent* - -* Fix migration compatibility to create SQLite references/belongs_to column as integer when migration version is 6.0. - - Reference/belongs_to in migrations with version 6.0 were creating columns as - bigint instead of integer for the SQLite Adapter. - - *Marcelo Lauxen* - -* Fix `QueryMethods#in_order_of` to handle empty order list. - - ```ruby - Post.in_order_of(:id, []).to_a - ``` - - Also more explicitly set the column as secondary order, so that any other - value is still ordered. - - *Jean Boussier* - -* Fix quoting of column aliases generated by calculation methods. - - Since the alias is derived from the table name, we can't assume the result - is a valid identifier. - - ```ruby - class Test < ActiveRecord::Base - self.table_name = '1abc' - end - Test.group(:id).count - # syntax error at or near "1" (ActiveRecord::StatementInvalid) - # LINE 1: SELECT COUNT(*) AS count_all, "1abc"."id" AS 1abc_id FROM "1... - ``` - - *Jean Boussier* - -* Add `authenticate_by` when using `has_secure_password`. - - `authenticate_by` is intended to replace code like the following, which - returns early when a user with a matching email is not found: - - ```ruby - User.find_by(email: "...")&.authenticate("...") - ``` - - Such code is vulnerable to timing-based enumeration attacks, wherein an - attacker can determine if a user account with a given email exists. After - confirming that an account exists, the attacker can try passwords associated - with that email address from other leaked databases, in case the user - re-used a password across multiple sites (a common practice). Additionally, - knowing an account email address allows the attacker to attempt a targeted - phishing ("spear phishing") attack. - - `authenticate_by` addresses the vulnerability by taking the same amount of - time regardless of whether a user with a matching email is found: - - ```ruby - User.authenticate_by(email: "...", password: "...") - ``` - - *Jonathan Hefner* - - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activerecord/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activerecord/CHANGELOG.md) for previous changes. diff --git a/activerecord/README.rdoc b/activerecord/README.rdoc index b430b17795a..07a07f47f21 100644 --- a/activerecord/README.rdoc +++ b/activerecord/README.rdoc @@ -139,7 +139,7 @@ A short rundown of some of the major features: * Database agnostic schema management with Migrations. - class AddSystemSettings < ActiveRecord::Migration[7.1] + class AddSystemSettings < ActiveRecord::Migration[7.2] def up create_table :system_settings do |t| t.string :name diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index b79c758bf48..c135d87bf60 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1905,7 +1905,7 @@ module ActiveRecord # The join table should not have a primary key or a model associated with it. You must manually generate the # join table with a migration such as this: # - # class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration[7.1] + # class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration[7.2] # def change # create_join_table :developers, :projects # end diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 1eb1ca23c3b..15f06d2419a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -348,7 +348,7 @@ module ActiveRecord # Inside migration files, the +t+ object in {create_table}[rdoc-ref:SchemaStatements#create_table] # is actually of this type: # - # class SomeMigration < ActiveRecord::Migration[7.1] + # class SomeMigration < ActiveRecord::Migration[7.2] # def up # create_table :foo do |t| # puts t.class # => "ActiveRecord::ConnectionAdapters::TableDefinition" diff --git a/activerecord/lib/active_record/gem_version.rb b/activerecord/lib/active_record/gem_version.rb index 3d8cd0264d8..669a6d2b28a 100644 --- a/activerecord/lib/active_record/gem_version.rb +++ b/activerecord/lib/active_record/gem_version.rb @@ -8,9 +8,9 @@ module ActiveRecord module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 27e3e833ce4..d3fc3b538c1 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -20,7 +20,7 @@ module ActiveRecord # For example the following migration is not reversible. # Rolling back this migration will raise an ActiveRecord::IrreversibleMigration error. # - # class IrreversibleMigrationExample < ActiveRecord::Migration[7.1] + # class IrreversibleMigrationExample < ActiveRecord::Migration[7.2] # def change # create_table :distributors do |t| # t.string :zipcode @@ -38,7 +38,7 @@ module ActiveRecord # # 1. Define #up and #down methods instead of #change: # - # class ReversibleMigrationExample < ActiveRecord::Migration[7.1] + # class ReversibleMigrationExample < ActiveRecord::Migration[7.2] # def up # create_table :distributors do |t| # t.string :zipcode @@ -63,7 +63,7 @@ module ActiveRecord # # 2. Use the #reversible method in #change method: # - # class ReversibleMigrationExample < ActiveRecord::Migration[7.1] + # class ReversibleMigrationExample < ActiveRecord::Migration[7.2] # def change # create_table :distributors do |t| # t.string :zipcode @@ -234,7 +234,7 @@ module ActiveRecord # # Example of a simple migration: # - # class AddSsl < ActiveRecord::Migration[7.1] + # class AddSsl < ActiveRecord::Migration[7.2] # def up # add_column :accounts, :ssl_enabled, :boolean, default: true # end @@ -254,7 +254,7 @@ module ActiveRecord # # Example of a more complex migration that also needs to initialize data: # - # class AddSystemSettings < ActiveRecord::Migration[7.1] + # class AddSystemSettings < ActiveRecord::Migration[7.2] # def up # create_table :system_settings do |t| # t.string :name @@ -382,7 +382,7 @@ module ActiveRecord # bin/rails generate migration add_fieldname_to_tablename fieldname:string # # This will generate the file timestamp_add_fieldname_to_tablename.rb, which will look like this: - # class AddFieldnameToTablename < ActiveRecord::Migration[7.1] + # class AddFieldnameToTablename < ActiveRecord::Migration[7.2] # def change # add_column :tablenames, :fieldname, :string # end @@ -408,7 +408,7 @@ module ActiveRecord # # Not all migrations change the schema. Some just fix the data: # - # class RemoveEmptyTags < ActiveRecord::Migration[7.1] + # class RemoveEmptyTags < ActiveRecord::Migration[7.2] # def up # Tag.all.each { |tag| tag.destroy if tag.pages.empty? } # end @@ -421,7 +421,7 @@ module ActiveRecord # # Others remove columns when they migrate up instead of down: # - # class RemoveUnnecessaryItemAttributes < ActiveRecord::Migration[7.1] + # class RemoveUnnecessaryItemAttributes < ActiveRecord::Migration[7.2] # def up # remove_column :items, :incomplete_items_count # remove_column :items, :completed_items_count @@ -435,7 +435,7 @@ module ActiveRecord # # And sometimes you need to do something in SQL not abstracted directly by migrations: # - # class MakeJoinUnique < ActiveRecord::Migration[7.1] + # class MakeJoinUnique < ActiveRecord::Migration[7.2] # def up # execute "ALTER TABLE `pages_linked_pages` ADD UNIQUE `page_id_linked_page_id` (`page_id`,`linked_page_id`)" # end @@ -452,7 +452,7 @@ module ActiveRecord # Base#reset_column_information in order to ensure that the model has the # latest column data from after the new column was added. Example: # - # class AddPeopleSalary < ActiveRecord::Migration[7.1] + # class AddPeopleSalary < ActiveRecord::Migration[7.2] # def up # add_column :people, :salary, :integer # Person.reset_column_information @@ -510,7 +510,7 @@ module ActiveRecord # To define a reversible migration, define the +change+ method in your # migration like this: # - # class TenderloveMigration < ActiveRecord::Migration[7.1] + # class TenderloveMigration < ActiveRecord::Migration[7.2] # def change # create_table(:horses) do |t| # t.column :content, :text @@ -540,7 +540,7 @@ module ActiveRecord # can't execute inside a transaction though, and for these situations # you can turn the automatic transactions off. # - # class ChangeEnum < ActiveRecord::Migration[7.1] + # class ChangeEnum < ActiveRecord::Migration[7.2] # disable_ddl_transaction! # # def up @@ -810,7 +810,7 @@ module ActiveRecord # and create the table 'apples' on the way up, and the reverse # on the way down. # - # class FixTLMigration < ActiveRecord::Migration[7.1] + # class FixTLMigration < ActiveRecord::Migration[7.2] # def change # revert do # create_table(:horses) do |t| @@ -829,7 +829,7 @@ module ActiveRecord # # require_relative "20121212123456_tenderlove_migration" # - # class FixupTLMigration < ActiveRecord::Migration[7.1] + # class FixupTLMigration < ActiveRecord::Migration[7.2] # def change # revert TenderloveMigration # @@ -880,7 +880,7 @@ module ActiveRecord # when the three columns 'first_name', 'last_name' and 'full_name' exist, # even when migrating down: # - # class SplitNameMigration < ActiveRecord::Migration[7.1] + # class SplitNameMigration < ActiveRecord::Migration[7.2] # def change # add_column :users, :first_name, :string # add_column :users, :last_name, :string @@ -908,7 +908,7 @@ module ActiveRecord # In the following example, the new column +published+ will be given # the value +true+ for all existing records. # - # class AddPublishedToPosts < ActiveRecord::Migration[7.1] + # class AddPublishedToPosts < ActiveRecord::Migration[7.2] # def change # add_column :posts, :published, :boolean, default: false # up_only do diff --git a/activerecord/lib/active_record/migration/compatibility.rb b/activerecord/lib/active_record/migration/compatibility.rb index 29cd887ee1d..4d5f50cf34a 100644 --- a/activerecord/lib/active_record/migration/compatibility.rb +++ b/activerecord/lib/active_record/migration/compatibility.rb @@ -21,8 +21,7 @@ module ActiveRecord # New migration functionality that will never be backward compatible should be added directly to `ActiveRecord::Migration`. # # There are classes for each prior Rails version. Each class descends from the *next* Rails version, so: - # 7.0 < 7.1 - # 5.2 < 6.0 < 6.1 < 7.0 < 7.1 + # 5.2 < 6.0 < 6.1 < 7.0 < 7.1 < 7.2 # # If you are introducing new migration functionality that should only apply from Rails 7 onward, then you should # find the class that immediately precedes it (6.1), and override the relevant migration methods to undo your changes. @@ -30,7 +29,10 @@ module ActiveRecord # For example, Rails 6 added a default value for the `precision` option on datetime columns. So in this file, the `V5_2` # class sets the value of `precision` to `nil` if it's not explicitly provided. This way, the default value will not apply # for migrations written for 5.2, but will for migrations written for 6.0. - V7_1 = Current + V7_2 = Current + + class V7_1 < V7_2 + end class V7_0 < V7_1 module LegacyIndexName diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 7da0499e4de..a7c988a616c 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -525,7 +525,7 @@ module ActiveRecord # when just after creating a table you want to populate it with some default # values, e.g.: # - # class CreateJobLevels < ActiveRecord::Migration[7.1] + # class CreateJobLevels < ActiveRecord::Migration[7.2] # def up # create_table :job_levels do |t| # t.integer :id diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md index 8d0c82a94be..7e8be1f4c89 100644 --- a/activestorage/CHANGELOG.md +++ b/activestorage/CHANGELOG.md @@ -1,242 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Add `expires_at` option to `ActiveStorage::Blob#signed_id`. - - ```ruby - rails_blob_path(user.avatar, disposition: "attachment", expires_at: 30.minutes.from_now) - <%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_at: 30.minutes.from_now) %> - ``` - - *Aki* - -* Allow attaching File and Pathname when assigning attributes, e.g. - - ```ruby - User.create!(avatar: File.open("image.jpg")) - User.create!(avatar: file_fixture("image.jpg")) - ``` - - *Dorian Marié* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Disables the session in `ActiveStorage::Blobs::ProxyController` - and `ActiveStorage::Representations::ProxyController` - in order to allow caching by default in some CDNs as CloudFlare - - Fixes #44136 - - *Bruno Prieto* - -* Add `tags` to `ActiveStorage::Analyzer::AudioAnalyzer` output - - *Keaton Roux* - -* Add an option to preprocess variants - - ActiveStorage variants are processed on the fly when they are needed but - sometimes we're sure that they are accessed and want to processed them - upfront. - - `preprocessed` option is added when declaring variants. - - ``` - class User < ApplicationRecord - has_one_attached :avatar do |attachable| - attachable.variant :thumb, resize_to_limit: [100, 100], preprocessed: true - end - end - ``` - - *Shouichi Kamiya* - -* Fix variants not included when eager loading multiple records containing a single attachment - - When using the `with_attached_#{name}` scope for a `has_one_attached` relation, - attachment variants were not eagerly loaded. - - *Russell Porter* - -* Allow an ActiveStorage attachment to be removed via a form post - - Attachments can already be removed by updating the attachment to be nil such as: - ```ruby - User.find(params[:id]).update!(avatar: nil) - ``` - - However, a form cannot post a nil param, it can only post an empty string. But, posting an - empty string would result in an `ActiveSupport::MessageVerifier::InvalidSignature: mismatched digest` - error being raised, because it's being treated as a signed blob id. - - Now, nil and an empty string are treated as a delete, which allows attachments to be removed via: - ```ruby - User.find(params[:id]).update!(params.require(:user).permit(:avatar)) - - ``` - - *Nate Matykiewicz* - -* Remove mini_mime usage in favour of marcel. - - We have two libraries that are have similar usage. This change removes - dependency on mini_mime and makes use of similar methods from marcel. - - *Vipul A M* - -* Allow destroying active storage variants - - ```ruby - User.first.avatar.variant(resize_to_limit: [100, 100]).destroy - ``` - - *Shouichi Kamiya*, *Yuichiro NAKAGAWA*, *Ryohei UEDA* - -* Add `sample_rate` to `ActiveStorage::Analyzer::AudioAnalyzer` output - - *Matija Čupić* - -* Remove deprecated `purge` and `purge_later` methods from the attachments association. - - *Rafael Mendonça França* - -* Remove deprecated behavior when assigning to a collection of attachments. - - Instead of appending to the collection, the collection is now replaced. - - *Rafael Mendonça França* - -* Remove deprecated `ActiveStorage::Current#host` and `ActiveStorage::Current#host=` methods. - - *Rafael Mendonça França* - -* Remove deprecated invalid default content types in Active Storage configurations. - - *Rafael Mendonça França* - -* Add missing preview event to `ActiveStorage::LogSubscriber` - - A `preview` event is being instrumented in `ActiveStorage::Previewer`. - However it was not added inside ActiveStorage's LogSubscriber class. - - This will allow to have logs for when a preview happens - in the same fashion as all other ActiveStorage events such as - `upload` and `download` inside `Rails.logger`. - - *Chedli Bourguiba* - -* Fix retrieving rotation value from FFmpeg on version 5.0+. - - In FFmpeg version 5.0+ the rotation value has been removed from tags. - Instead the value can be found in side_data_list. Along with - this update it's possible to have values of -90, -270 to denote the video - has been rotated. - - *Haroon Ahmed* - -* Touch all corresponding model records after ActiveStorage::Blob is analyzed - - This fixes a race condition where a record can be requested and have a cache entry built, before - the initial `analyze_later` completes, which will not be invalidated until something else - updates the record. This also invalidates cache entries when a blob is re-analyzed, which - is helpful if a bug is fixed in an analyzer or a new analyzer is added. - - *Nate Matykiewicz* - -* Add ability to use pre-defined variants when calling `preview` or - `representation` on an attachment. - - ```ruby - class User < ActiveRecord::Base - has_one_attached :file do |attachable| - attachable.variant :thumb, resize_to_limit: [100, 100] - end - end - - <%= image_tag user.file.representation(:thumb) %> - ``` - - *Richard Böhme* - -* Method `attach` always returns the attachments except when the record - is persisted, unchanged, and saving it fails, in which case it returns `nil`. - - *Santiago Bartesaghi* - -* Fixes multiple `attach` calls within transaction not uploading files correctly. - - In the following example, the code failed to upload all but the last file to the configured service. - ```ruby - ActiveRecord::Base.transaction do - user.attachments.attach({ - content_type: "text/plain", - filename: "dummy.txt", - io: ::StringIO.new("dummy"), - }) - user.attachments.attach({ - content_type: "text/plain", - filename: "dummy2.txt", - io: ::StringIO.new("dummy2"), - }) - end - - assert_equal 2, user.attachments.count - assert user.attachments.first.service.exist?(user.attachments.first.key) # Fails - ``` - - This was addressed by keeping track of the subchanges pending upload, and uploading them - once the transaction is committed. - - Fixes #41661 - - *Santiago Bartesaghi*, *Bruno Vezoli*, *Juan Roig*, *Abhay Nikam* - -* Raise an exception if `config.active_storage.service` is not set. - - If Active Storage is configured and `config.active_storage.service` is not - set in the respective environment's configuration file, then an exception - is raised with a meaningful message when attempting to use Active Storage. - - *Ghouse Mohamed* - -* Fixes proxy downloads of files over 5mb - - Previously, trying to view and/or download files larger than 5mb stored in - services like S3 via proxy mode could return corrupted files at around - 5.2mb or cause random halts in the download. Now, - `ActiveStorage::Blobs::ProxyController` correctly handles streaming these - larger files from the service to the client without any issues. - - Fixes #44679 - - *Felipe Raul* - -* Saving attachment(s) to a record returns the blob/blobs object - - Previously, saving attachments did not return the blob/blobs that - were attached. Now, saving attachments to a record with `#attach` - method returns the blob or array of blobs that were attached to - the record. If it fails to save the attachment(s), then it returns - `false`. - - *Ghouse Mohamed* - -* Don't stream responses in redirect mode - - Previously, both redirect mode and proxy mode streamed their - responses which caused a new thread to be created, and could end - up leaking connections in the connection pool. But since redirect - mode doesn't actually send any data, it doesn't need to be - streamed. - - *Luke Lau* - -* Safe for direct upload on Libraries or Frameworks - - Enable the use of custom headers during direct uploads, which allows for - the inclusion of Authorization bearer tokens or other forms of authorization - tokens through headers. - - *Radamés Roriz* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activestorage/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activestorage/CHANGELOG.md) for previous changes. diff --git a/activestorage/lib/active_storage/gem_version.rb b/activestorage/lib/active_storage/gem_version.rb index 733587feee6..1728ca10862 100644 --- a/activestorage/lib/active_storage/gem_version.rb +++ b/activestorage/lib/active_storage/gem_version.rb @@ -8,9 +8,9 @@ module ActiveStorage module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activestorage/package.json b/activestorage/package.json index aaa44919cf6..f29b199ec3a 100644 --- a/activestorage/package.json +++ b/activestorage/package.json @@ -1,6 +1,6 @@ { "name": "@rails/activestorage", - "version": "7.1.0-rc1", + "version": "7.2.0-alpha", "description": "Attach cloud and local files in Rails applications", "module": "app/assets/javascripts/activestorage.esm.js", "main": "app/assets/javascripts/activestorage.js", diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index ac70fcd6ca6..4dcf958b9d8 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,1062 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Add a new public API for broadcasting logs - - This feature existed for a while but was until now a private API. - Broadcasting log allows to send log message to difference sinks (STDOUT, a file ...) and - is used by default in the development environment to write logs both on STDOUT and in the - "development.log" file. - - Basic usage: - - ```ruby - stdout_logger = Logger.new(STDOUT) - file_logger = Logger.new("development.log") - broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger, file_logger) - - broadcast.info("Hello!") # The "Hello!" message is written on STDOUT and in the log file. - ``` - - Adding other sink(s) to the broadcast: - - ```ruby - broadcast = ActiveSupport::BroadcastLogger.new - broadcast.broadcast_to(Logger.new(STDERR)) - ``` - - Remove a sink from the broadcast: - - ```ruby - stdout_logger = Logger.new(STDOUT) - broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger) - - broadcast.stop_broadcasting_to(stdout_logger) - ``` - - *Edouard Chin* - -* Fix Range#overlap? not taking empty ranges into account on Ruby < 3.3 - - *Nobuyoshi Nakada*, *Shouichi Kamiya*, *Hartley McGuire* - -* Use Ruby 3.3 Range#overlap? if available - - *Yasuo Honda* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Add `bigdecimal` as Active Support dependency that is a bundled gem candidate for Ruby 3.4. - - `bigdecimal` 3.1.4 or higher version will be installed. - Ruby 2.7 and 3.0 users who want `bigdecimal` version 2.0.0 or 3.0.0 behavior as a default gem, - pin the `bigdecimal` version in your application Gemfile. - - *Koichi ITO* - -* Add `drb`, `mutex_m` and `base64` that are bundled gem candidates for Ruby 3.4 - - *Yasuo Honda* - -* When using cache format version >= 7.1 or a custom serializer, expired and - version-mismatched cache entries can now be detected without deserializing - their values. - - *Jonathan Hefner* - -* Make all cache stores return a boolean for `#delete` - - Previously the `RedisCacheStore#delete` would return `1` if the entry - exists and `0` otherwise. Now it returns true if the entry exists and false - otherwise, just like the other stores. - - The `FileStore` would return `nil` if the entry doesn't exists and returns - `false` now as well. - - *Petrik de Heus* - -* Active Support cache stores now support replacing the default compressor via - a `:compressor` option. The specified compressor must respond to `deflate` - and `inflate`. For example: - - ```ruby - module MyCompressor - def self.deflate(string) - # compression logic... - end - - def self.inflate(compressed) - # decompression logic... - end - end - - config.cache_store = :redis_cache_store, { compressor: MyCompressor } - ``` - - *Jonathan Hefner* - -* Active Support cache stores now support a `:serializer` option. Similar to - the `:coder` option, serializers must respond to `dump` and `load`. However, - serializers are only responsible for serializing a cached value, whereas - coders are responsible for serializing the entire `ActiveSupport::Cache::Entry` - instance. Additionally, the output from serializers can be automatically - compressed, whereas coders are responsible for their own compression. - - Specifying a serializer instead of a coder also enables performance - optimizations, including the bare string optimization introduced by cache - format version 7.1. - - The `:serializer` and `:coder` options are mutually exclusive. Specifying - both will raise an `ArgumentError`. - - *Jonathan Hefner* - -* Fix `ActiveSupport::Inflector.humanize(nil)` raising ``NoMethodError: undefined method `end_with?' for nil:NilClass``. - - *James Robinson* - -* Don't show secrets for `ActiveSupport::KeyGenerator#inspect`. - - Before: - - ```ruby - ActiveSupport::KeyGenerator.new(secret).inspect - "#" - ``` - - After: - - ```ruby - ActiveSupport::KeyGenerator::Aes256Gcm(secret).inspect - "#" - ``` - - *Petrik de Heus* - -* Improve error message when EventedFileUpdateChecker is used without a - compatible version of the Listen gem - - *Hartley McGuire* - -* Add `:report` behavior for Deprecation - - Setting `config.active_support.deprecation = :report` uses the error - reporter to report deprecation warnings to `ActiveSupport::ErrorReporter`. - - Deprecations are reported as handled errors, with a severity of `:warning`. - - Useful to report deprecations happening in production to your bug tracker. - - *Étienne Barrié* - -* Rename `Range#overlaps?` to `#overlap?` and add alias for backwards compatibility - - *Christian Schmidt* - -* Fix `EncryptedConfiguration` returning incorrect values for some `Hash` - methods - - *Hartley McGuire* - -* Don't show secrets for `MessageEncryptor#inspect`. - - Before: - - ```ruby - ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect - "#" - ``` - - After: - - ```ruby - ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect - "#" - ``` - - *Petrik de Heus* - -* Don't show contents for `EncryptedConfiguration#inspect`. - - Before: - ```ruby - Rails.application.credentials.inspect - "#\"something secret\"} ... @key_file_contents=\"915e4ea054e011022398dc242\" ...>" - ``` - - After: - ```ruby - Rails.application.credentials.inspect - "#" - ``` - - *Petrik de Heus* - -* `ERB::Util.html_escape_once` always returns an `html_safe` string. - - This method previously maintained the `html_safe?` property of a string on the return - value. Because this string has been escaped, however, not marking it as `html_safe` causes - entities to be double-escaped. - - As an example, take this view snippet: - - ```html -

<%= html_escape_once("this & that & the other") %>

- ``` - - Before this change, that would be double-escaped and render as: - - ```html -

this &amp; that &amp; the other

- ``` - - After this change, it renders correctly as: - - ```html -

this & that & the other

- ``` - - Fixes #48256 - - *Mike Dalessio* - -* Deprecate `SafeBuffer#clone_empty`. - - This method has not been used internally since Rails 4.2.0. - - *Mike Dalessio* - -* `MessageEncryptor`, `MessageVerifier`, and `config.active_support.message_serializer` - now accept `:message_pack` and `:message_pack_allow_marshal` as serializers. - These serializers require the [`msgpack` gem](https://rubygems.org/gems/msgpack) - (>= 1.7.0). - - The Message Pack format can provide improved performance and smaller payload - sizes. It also supports round-tripping some Ruby types that are not supported - by JSON. For example: - - ```ruby - verifier = ActiveSupport::MessageVerifier.new("secret") - data = [{ a: 1 }, { b: 2 }.with_indifferent_access, 1.to_d, Time.at(0, 123)] - message = verifier.generate(data) - - # BEFORE with config.active_support.message_serializer = :json - verifier.verified(message) - # => [{"a"=>1}, {"b"=>2}, "1.0", "1969-12-31T18:00:00.000-06:00"] - verifier.verified(message).map(&:class) - # => [Hash, Hash, String, String] - - # AFTER with config.active_support.message_serializer = :message_pack - verifier.verified(message) - # => [{:a=>1}, {"b"=>2}, 0.1e1, 1969-12-31 18:00:00.000123 -0600] - verifier.verified(message).map(&:class) - # => [Hash, ActiveSupport::HashWithIndifferentAccess, BigDecimal, Time] - ``` - - The `:message_pack` serializer can fall back to deserializing with - `ActiveSupport::JSON` when necessary, and the `:message_pack_allow_marshal` - serializer can fall back to deserializing with `Marshal` as well as - `ActiveSupport::JSON`. Additionally, the `:marshal`, `:json`, and - `:json_allow_marshal` serializers can now fall back to deserializing with - `ActiveSupport::MessagePack` when necessary. These behaviors ensure old - messages can still be read so that migration is easier. - - *Jonathan Hefner* - -* A new `7.1` cache format is available which includes an optimization for - bare string values such as view fragments. - - The `7.1` cache format is used by default for new apps, and existing apps - can enable the format by setting `config.load_defaults 7.1` or by setting - `config.active_support.cache_format_version = 7.1` in `config/application.rb` - or a `config/environments/*.rb` file. - - Cache entries written using the `6.1` or `7.0` cache formats can be read - when using the `7.1` format. To perform a rolling deploy of a Rails 7.1 - upgrade, wherein servers that have not yet been upgraded must be able to - read caches from upgraded servers, leave the cache format unchanged on the - first deploy, then enable the `7.1` cache format on a subsequent deploy. - - *Jonathan Hefner* - -* Active Support cache stores can now use a preconfigured serializer based on - `ActiveSupport::MessagePack` via the `:serializer` option: - - ```ruby - config.cache_store = :redis_cache_store, { serializer: :message_pack } - ``` - - The `:message_pack` serializer can reduce cache entry sizes and improve - performance, but requires the [`msgpack` gem](https://rubygems.org/gems/msgpack) - (>= 1.7.0). - - The `:message_pack` serializer can read cache entries written by the default - serializer, and the default serializer can now read entries written by the - `:message_pack` serializer. These behaviors make it easy to migrate between - serializer without invalidating the entire cache. - - *Jonathan Hefner* - -* `Object#deep_dup` no longer duplicate named classes and modules. - - Before: - - ```ruby - hash = { class: Object, module: Kernel } - hash.deep_dup # => {:class=>#, :module=>#} - ``` - - After: - - ```ruby - hash = { class: Object, module: Kernel } - hash.deep_dup # => {:class=>Object, :module=>Kernel} - ``` - - *Jean Boussier* - -* Consistently raise an `ArgumentError` if the `ActiveSupport::Cache` key is blank. - - *Joshua Young* - -* Deprecate usage of the singleton `ActiveSupport::Deprecation`. - - All usage of `ActiveSupport::Deprecation` as a singleton is deprecated, the most common one being - `ActiveSupport::Deprecation.warn`. Gem authors should now create their own deprecator (`ActiveSupport::Deprecation` - object), and use it to emit deprecation warnings. - - Calling any of the following without specifying a deprecator argument is also deprecated: - * Module.deprecate - * deprecate_constant - * DeprecatedObjectProxy - * DeprecatedInstanceVariableProxy - * DeprecatedConstantProxy - * deprecation-related test assertions - - Use of `ActiveSupport::Deprecation.silence` and configuration methods like `behavior=`, `disallowed_behavior=`, - `disallowed_warnings=` should now be aimed at the [application's deprecators](https://api.rubyonrails.org/classes/Rails/Application.html#method-i-deprecators). - - ```ruby - Rails.application.deprecators.silence do - # code that emits deprecation warnings - end - ``` - - If your gem has a Railtie or Engine, it's encouraged to add your deprecator to the application's deprecators, that - way the deprecation related configuration options will apply to it as well, e.g. - `config.active_support.report_deprecations` set to `false` in the production environment will also disable your - deprecator. - - ```ruby - initializer "my_gem.deprecator" do |app| - app.deprecators[:my_gem] = MyGem.deprecator - end - ``` - - *Étienne Barrié* - -* Add `Object#with` to set and restore public attributes around a block - - ```ruby - client.timeout # => 5 - client.with(timeout: 1) do - client.timeout # => 1 - end - client.timeout # => 5 - ``` - - *Jean Boussier* - -* Remove deprecated support to generate incorrect RFC 4122 UUIDs when providing a namespace ID that is not one of the - constants defined on `Digest::UUID`. - - *Rafael Mendonça França* - -* Deprecate `config.active_support.use_rfc4122_namespaced_uuids`. - - *Rafael Mendonça França* - -* Remove implicit conversion of objects into `String` by `ActiveSupport::SafeBuffer`. - - *Rafael Mendonça França* - -* Remove deprecated `active_support/core_ext/range/include_time_with_zone` file. - - *Rafael Mendonça França* - -* Deprecate `config.active_support.remove_deprecated_time_with_zone_name`. - - *Rafael Mendonça França* - -* Remove deprecated override of `ActiveSupport::TimeWithZone.name`. - - *Rafael Mendonça França* - -* Deprecate `config.active_support.disable_to_s_conversion`. - - *Rafael Mendonça França* - -* Remove deprecated option to passing a format to `#to_s` in `Array`, `Range`, `Date`, `DateTime`, `Time`, - `BigDecimal`, `Float` and, `Integer`. - - *Rafael Mendonça França* - -* Remove deprecated `ActiveSupport::PerThreadRegistry`. - - *Rafael Mendonça França* - -* Remove deprecated override of `Enumerable#sum`. - - *Rafael Mendonça França* - -* Deprecated initializing a `ActiveSupport::Cache::MemCacheStore` with an instance of `Dalli::Client`. - - Deprecate the undocumented option of providing an already-initialized instance of `Dalli::Client` to `ActiveSupport::Cache::MemCacheStore`. Such clients could be configured with unrecognized options, which could lead to unexpected behavior. Instead, provide addresses as documented. - - *aledustet* - -* Stub `Time.new()` in `TimeHelpers#travel_to` - - ```ruby - travel_to Time.new(2004, 11, 24) do - # Inside the `travel_to` block `Time.new` is stubbed - assert_equal 2004, Time.new.year - end - ``` - - *fatkodima* - -* Raise `ActiveSupport::MessageEncryptor::InvalidMessage` from - `ActiveSupport::MessageEncryptor#decrypt_and_verify` regardless of cipher. - Previously, when a `MessageEncryptor` was using a non-AEAD cipher such as - AES-256-CBC, a corrupt or tampered message would raise - `ActiveSupport::MessageVerifier::InvalidSignature`. Now, all ciphers raise - the same error: - - ```ruby - encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-gcm") - message = encryptor.encrypt_and_sign("message") - encryptor.decrypt_and_verify(message.next) - # => raises ActiveSupport::MessageEncryptor::InvalidMessage - - encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-cbc") - message = encryptor.encrypt_and_sign("message") - encryptor.decrypt_and_verify(message.next) - # BEFORE: - # => raises ActiveSupport::MessageVerifier::InvalidSignature - # AFTER: - # => raises ActiveSupport::MessageEncryptor::InvalidMessage - ``` - - *Jonathan Hefner* - -* Support `nil` original values when using `ActiveSupport::MessageVerifier#verify`. - Previously, `MessageVerifier#verify` did not work with `nil` original - values, though both `MessageVerifier#verified` and - `MessageEncryptor#decrypt_and_verify` do: - - ```ruby - encryptor = ActiveSupport::MessageEncryptor.new(secret) - message = encryptor.encrypt_and_sign(nil) - - encryptor.decrypt_and_verify(message) - # => nil - - verifier = ActiveSupport::MessageVerifier.new(secret) - message = verifier.generate(nil) - - verifier.verified(message) - # => nil - - verifier.verify(message) - # BEFORE: - # => raises ActiveSupport::MessageVerifier::InvalidSignature - # AFTER: - # => nil - ``` - - *Jonathan Hefner* - -* Maintain `html_safe?` on html_safe strings when sliced with `slice`, `slice!`, or `chr` method. - - Previously, `html_safe?` was only maintained when the html_safe strings were sliced - with `[]` method. Now, `slice`, `slice!`, and `chr` methods will maintain `html_safe?` like `[]` method. - - ```ruby - string = "
test
".html_safe - string.slice(0, 1).html_safe? # => true - string.slice!(0, 1).html_safe? # => true - # maintain html_safe? after the slice! - string.html_safe? # => true - string.chr.html_safe? # => true - ``` - - *Michael Go* - -* Add `Object#in?` support for open ranges. - - ```ruby - assert Date.today.in?(..Date.tomorrow) - assert_not Date.today.in?(Date.tomorrow..) - ``` - - *Ignacio Galindo* - -* `config.i18n.raise_on_missing_translations = true` now raises on any missing translation. - - Previously it would only raise when called in a view or controller. Now it will raise - anytime `I18n.t` is provided an unrecognised key. - - If you do not want this behaviour, you can customise the i18n exception handler. See the - upgrading guide or i18n guide for more information. - - *Alex Ghiculescu* - -* `ActiveSupport::CurrentAttributes` now raises if a restricted attribute name is used. - - Attributes such as `set` and `reset` cannot be used as they clash with the - `CurrentAttributes` public API. - - *Alex Ghiculescu* - -* `HashWithIndifferentAccess#transform_keys` now takes a Hash argument, just - as Ruby's `Hash#transform_keys` does. - - *Akira Matsuda* - -* `delegate` now defines method with proper arity when delegating to a Class. - With this change, it defines faster method (3.5x faster with no argument). - However, in order to gain this benefit, the delegation target method has to - be defined before declaring the delegation. - - ```ruby - # This defines 3.5 times faster method than before - class C - def self.x() end - delegate :x, to: :class - end - - class C - # This works but silently falls back to old behavior because - # `delegate` cannot find the definition of `x` - delegate :x, to: :class - def self.x() end - end - ``` - - *Akira Matsuda* - -* `assert_difference` message now includes what changed. - - This makes it easier to debug non-obvious failures. - - Before: - - ``` - "User.count" didn't change by 32. - Expected: 1611 - Actual: 1579 - ``` - - After: - - ``` - "User.count" didn't change by 32, but by 0. - Expected: 1611 - Actual: 1579 - ``` - - *Alex Ghiculescu* - -* Add ability to match exception messages to `assert_raises` assertion - - Instead of this - ```ruby - error = assert_raises(ArgumentError) do - perform_service(param: 'exception') - end - assert_match(/incorrect param/i, error.message) - ``` - - you can now write this - ```ruby - assert_raises(ArgumentError, match: /incorrect param/i) do - perform_service(param: 'exception') - end - ``` - - *fatkodima* - -* Add `Rails.env.local?` shorthand for `Rails.env.development? || Rails.env.test?`. - - *DHH* - -* `ActiveSupport::Testing::TimeHelpers` now accepts named `with_usec` argument - to `freeze_time`, `travel`, and `travel_to` methods. Passing true prevents - truncating the destination time with `change(usec: 0)`. - - *KevSlashNull*, and *serprex* - -* `ActiveSupport::CurrentAttributes.resets` now accepts a method name - - The block API is still the recommended approach, but now both APIs are supported: - - ```ruby - class Current < ActiveSupport::CurrentAttributes - resets { Time.zone = nil } - resets :clear_time_zone - end - ``` - - *Alex Ghiculescu* - -* Ensure `ActiveSupport::Testing::Isolation::Forking` closes pipes - - Previously, `Forking.run_in_isolation` opened two ends of a pipe. The fork - process closed the read end, wrote to it, and then terminated (which - presumably closed the file descriptors on its end). The parent process - closed the write end, read from it, and returned, never closing the read - end. - - This resulted in an accumulation of open file descriptors, which could - cause errors if the limit is reached. - - *Sam Bostock* - -* Fix `Time#change` and `Time#advance` for times around the end of Daylight - Saving Time. - - Previously, when `Time#change` or `Time#advance` constructed a time inside - the final stretch of Daylight Saving Time (DST), the non-DST offset would - always be chosen for local times: - - ```ruby - # DST ended just before 2021-11-07 2:00:00 AM in US/Eastern. - ENV["TZ"] = "US/Eastern" - - time = Time.local(2021, 11, 07, 00, 59, 59) + 1 - # => 2021-11-07 01:00:00 -0400 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0500 - time.advance(seconds: 0) - # => 2021-11-07 01:00:00 -0500 - - time = Time.local(2021, 11, 06, 01, 00, 00) - # => 2021-11-06 01:00:00 -0400 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0500 - time.advance(days: 1) - # => 2021-11-07 01:00:00 -0500 - ``` - - And the DST offset would always be chosen for times with a `TimeZone` - object: - - ```ruby - Time.zone = "US/Eastern" - - time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600 - # => 2021-11-07 01:00:00 -0500 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0400 - time.advance(seconds: 0) - # => 2021-11-07 01:00:00 -0400 - - time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone) - # => 2021-11-08 01:00:00 -0500 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0400 - time.advance(days: -1) - # => 2021-11-07 01:00:00 -0400 - ``` - - Now, `Time#change` and `Time#advance` will choose the offset that matches - the original time's offset when possible: - - ```ruby - ENV["TZ"] = "US/Eastern" - - time = Time.local(2021, 11, 07, 00, 59, 59) + 1 - # => 2021-11-07 01:00:00 -0400 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0400 - time.advance(seconds: 0) - # => 2021-11-07 01:00:00 -0400 - - time = Time.local(2021, 11, 06, 01, 00, 00) - # => 2021-11-06 01:00:00 -0400 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0400 - time.advance(days: 1) - # => 2021-11-07 01:00:00 -0400 - - Time.zone = "US/Eastern" - - time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600 - # => 2021-11-07 01:00:00 -0500 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0500 - time.advance(seconds: 0) - # => 2021-11-07 01:00:00 -0500 - - time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone) - # => 2021-11-08 01:00:00 -0500 - time.change(day: 07) - # => 2021-11-07 01:00:00 -0500 - time.advance(days: -1) - # => 2021-11-07 01:00:00 -0500 - ``` - - *Kevin Hall*, *Takayoshi Nishida*, and *Jonathan Hefner* - -* Fix MemoryStore to preserve entries TTL when incrementing or decrementing - - This is to be more consistent with how MemCachedStore and RedisCacheStore behaves. - - *Jean Boussier* - -* `Rails.error.handle` and `Rails.error.record` filter now by multiple error classes. - - ```ruby - Rails.error.handle(IOError, ArgumentError) do - 1 + '1' # raises TypeError - end - 1 + 1 # TypeErrors are not IOErrors or ArgumentError, so this will *not* be handled - ``` - - *Martin Spickermann* - -* `Class#subclasses` and `Class#descendants` now automatically filter reloaded classes. - - Previously they could return old implementations of reloadable classes that have been - dereferenced but not yet garbage collected. - - They now automatically filter such classes like `DescendantTracker#subclasses` and - `DescendantTracker#descendants`. - - *Jean Boussier* - -* `Rails.error.report` now marks errors as reported to avoid reporting them twice. - - In some cases, users might want to report errors explicitly with some extra context - before letting it bubble up. - - This also allows to safely catch and report errors outside of the execution context. - - *Jean Boussier* - -* Add `assert_error_reported` and `assert_no_error_reported` - - Allows to easily asserts an error happened but was handled - - ```ruby - report = assert_error_reported(IOError) do - # ... - end - assert_equal "Oops", report.error.message - assert_equal "admin", report.context[:section] - assert_equal :warning, report.severity - assert_predicate report, :handled? - ``` - - *Jean Boussier* - -* `ActiveSupport::Deprecation` behavior callbacks can now receive the - deprecator instance as an argument. This makes it easier for such callbacks - to change their behavior based on the deprecator's state. For example, - based on the deprecator's `debug` flag. - - 3-arity and splat-args callbacks such as the following will now be passed - the deprecator instance as their third argument: - - * `->(message, callstack, deprecator) { ... }` - * `->(*args) { ... }` - * `->(message, *other_args) { ... }` - - 2-arity and 4-arity callbacks such as the following will continue to behave - the same as before: - - * `->(message, callstack) { ... }` - * `->(message, callstack, deprecation_horizon, gem_name) { ... }` - * `->(message, callstack, *deprecation_details) { ... }` - - *Jonathan Hefner* - -* `ActiveSupport::Deprecation#disallowed_warnings` now affects the instance on - which it is configured. - - This means that individual `ActiveSupport::Deprecation` instances can be - configured with their own disallowed warnings, and the global - `ActiveSupport::Deprecation.disallowed_warnings` now only affects the global - `ActiveSupport::Deprecation.warn`. - - **Before** - - ```ruby - ActiveSupport::Deprecation.disallowed_warnings = ["foo"] - deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem") - deprecator.disallowed_warnings = ["bar"] - - ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException - ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar" - deprecator.warn("foo") # => raise ActiveSupport::DeprecationException - deprecator.warn("bar") # => print "DEPRECATION WARNING: bar" - ``` - - **After** - - ```ruby - ActiveSupport::Deprecation.disallowed_warnings = ["foo"] - deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem") - deprecator.disallowed_warnings = ["bar"] - - ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException - ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar" - deprecator.warn("foo") # => print "DEPRECATION WARNING: foo" - deprecator.warn("bar") # => raise ActiveSupport::DeprecationException - ``` - - Note that global `ActiveSupport::Deprecation` methods such as `ActiveSupport::Deprecation.warn` - and `ActiveSupport::Deprecation.disallowed_warnings` have been deprecated. - - *Jonathan Hefner* - -* Add italic and underline support to `ActiveSupport::LogSubscriber#color` - - Previously, only bold text was supported via a positional argument. - This allows for bold, italic, and underline options to be specified - for colored logs. - - ```ruby - info color("Hello world!", :red, bold: true, underline: true) - ``` - - *Gannon McGibbon* - -* Add `String#downcase_first` method. - - This method is the corollary of `String#upcase_first`. - - *Mark Schneider* - -* `thread_mattr_accessor` will call `.dup.freeze` on non-frozen default values. - - This provides a basic level of protection against different threads trying - to mutate a shared default object. - - *Jonathan Hefner* - -* Add `raise_on_invalid_cache_expiration_time` config to `ActiveSupport::Cache::Store` - - Specifies if an `ArgumentError` should be raised if `Rails.cache` `fetch` or - `write` are given an invalid `expires_at` or `expires_in` time. - - Options are `true`, and `false`. If `false`, the exception will be reported - as `handled` and logged instead. Defaults to `true` if `config.load_defaults >= 7.1`. - - *Trevor Turk* - -* `ActiveSupport::Cache:Store#fetch` now passes an options accessor to the block. - - It makes possible to override cache options: - - Rails.cache.fetch("3rd-party-token") do |name, options| - token = fetch_token_from_remote - # set cache's TTL to match token's TTL - options.expires_in = token.expires_in - token - end - - *Andrii Gladkyi*, *Jean Boussier* - -* `default` option of `thread_mattr_accessor` now applies through inheritance and - also across new threads. - - Previously, the `default` value provided was set only at the moment of defining - the attribute writer, which would cause the attribute to be uninitialized in - descendants and in other threads. - - Fixes #43312. - - *Thierry Deo* - -* Redis cache store is now compatible with redis-rb 5.0. - - *Jean Boussier* - -* Add `skip_nil:` support to `ActiveSupport::Cache::Store#fetch_multi`. - - *Daniel Alfaro* - -* Add `quarter` method to date/time - - *Matt Swanson* - -* Fix `NoMethodError` on custom `ActiveSupport::Deprecation` behavior. - - `ActiveSupport::Deprecation.behavior=` was supposed to accept any object - that responds to `call`, but in fact its internal implementation assumed that - this object could respond to `arity`, so it was restricted to only `Proc` objects. - - This change removes this `arity` restriction of custom behaviors. - - *Ryo Nakamura* - -* Support `:url_safe` option for `MessageEncryptor`. - - The `MessageEncryptor` constructor now accepts a `:url_safe` option, similar - to the `MessageVerifier` constructor. When enabled, this option ensures - that messages use a URL-safe encoding. - - *Jonathan Hefner* - -* Add `url_safe` option to `ActiveSupport::MessageVerifier` initializer - - `ActiveSupport::MessageVerifier.new` now takes optional `url_safe` argument. - It can generate URL-safe strings by passing `url_safe: true`. - - ```ruby - verifier = ActiveSupport::MessageVerifier.new(url_safe: true) - message = verifier.generate(data) # => URL-safe string - ``` - - This option is `false` by default to be backwards compatible. - - *Shouichi Kamiya* - -* Enable connection pooling by default for `MemCacheStore` and `RedisCacheStore`. - - If you want to disable connection pooling, set `:pool` option to `false` when configuring the cache store: - - ```ruby - config.cache_store = :mem_cache_store, "cache.example.com", pool: false - ``` - - *fatkodima* - -* Add `force:` support to `ActiveSupport::Cache::Store#fetch_multi`. - - *fatkodima* - -* Deprecated `:pool_size` and `:pool_timeout` options for configuring connection pooling in cache stores. - - Use `pool: true` to enable pooling with default settings: - - ```ruby - config.cache_store = :redis_cache_store, pool: true - ``` - - Or pass individual options via `:pool` option: - - ```ruby - config.cache_store = :redis_cache_store, pool: { size: 10, timeout: 2 } - ``` - - *fatkodima* - -* Allow #increment and #decrement methods of `ActiveSupport::Cache::Store` - subclasses to set new values. - - Previously incrementing or decrementing an unset key would fail and return - nil. A default will now be assumed and the key will be created. - - *Andrej Blagojević*, *Eugene Kenny* - -* Add `skip_nil:` support to `RedisCacheStore` - - *Joey Paris* - -* `ActiveSupport::Cache::MemoryStore#write(name, val, unless_exist:true)` now - correctly writes expired keys. - - *Alan Savage* - -* `ActiveSupport::ErrorReporter` now accepts and forward a `source:` parameter. - - This allow libraries to signal the origin of the errors, and reporters - to easily ignore some sources. - - *Jean Boussier* - -* Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`. - - Add the method `ERB::Util.xml_name_escape` to escape dangerous characters - in names of tags and names of attributes, following the specification of XML. - - *Álvaro Martín Fraguas* - -* Respect `ActiveSupport::Logger.new`'s `:formatter` keyword argument - - The stdlib `Logger::new` allows passing a `:formatter` keyword argument to - set the logger's formatter. Previously `ActiveSupport::Logger.new` ignored - that argument by always setting the formatter to an instance of - `ActiveSupport::Logger::SimpleFormatter`. - - *Steven Harman* - -* Deprecate preserving the pre-Ruby 2.4 behavior of `to_time` - - With Ruby 2.4+ the default for +to_time+ changed from converting to the - local system time to preserving the offset of the receiver. At the time Rails - supported older versions of Ruby so a compatibility layer was added to assist - in the migration process. From Rails 5.0 new applications have defaulted to - the Ruby 2.4+ behavior and since Rails 7.0 now only supports Ruby 2.7+ - this compatibility layer can be safely removed. - - To minimize any noise generated the deprecation warning only appears when the - setting is configured to `false` as that is the only scenario where the - removal of the compatibility layer has any effect. - - *Andrew White* - -* `Pathname.blank?` only returns true for `Pathname.new("")` - - Previously it would end up calling `Pathname#empty?` which returned true - if the path existed and was an empty directory or file. - - That behavior was unlikely to be expected. - - *Jean Boussier* - -* Deprecate `Notification::Event`'s `#children` and `#parent_of?` - - *John Hawthorn* - -* Change the default serializer of `ActiveSupport::MessageVerifier` from - `Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`. - - Messages serialized with `Marshal` can still be read, but new messages will - be serialized with `ActiveSupport::JSON`. For more information, see - https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer. - - *Saba Kiaei*, *David Buckley*, and *Jonathan Hefner* - -* Change the default serializer of `ActiveSupport::MessageEncryptor` from - `Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`. - - Messages serialized with `Marshal` can still be read, but new messages will - be serialized with `ActiveSupport::JSON`. For more information, see - https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer. - - *Zack Deveau*, *Martin Gingras*, and *Jonathan Hefner* - -* Add `ActiveSupport::TestCase#stub_const` to stub a constant for the duration of a yield. - - *DHH* - -* Fix `ActiveSupport::EncryptedConfiguration` to be compatible with Psych 4 - - *Stephen Sugden* - -* Improve `File.atomic_write` error handling - - *Daniel Pepper* - -* Fix `Class#descendants` and `DescendantsTracker#descendants` compatibility with Ruby 3.1. - - [The native `Class#descendants` was reverted prior to Ruby 3.1 release](https://bugs.ruby-lang.org/issues/14394#note-33), - but `Class#subclasses` was kept, breaking the feature detection. - - *Jean Boussier* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activesupport/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activesupport/CHANGELOG.md) for previous changes. diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 1feb4af2f7c..ad96ecb946f 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -65,7 +65,7 @@ module ActiveSupport # and the second is a library name. # # ActiveSupport::Deprecation.new('2.0', 'MyLibrary') - def initialize(deprecation_horizon = "7.2", gem_name = "Rails") + def initialize(deprecation_horizon = "7.3", gem_name = "Rails") self.gem_name = gem_name self.deprecation_horizon = deprecation_horizon # By default, warnings are not silenced and debugging is off. diff --git a/activesupport/lib/active_support/gem_version.rb b/activesupport/lib/active_support/gem_version.rb index 775b21d3a56..eada318028a 100644 --- a/activesupport/lib/active_support/gem_version.rb +++ b/activesupport/lib/active_support/gem_version.rb @@ -8,9 +8,9 @@ module ActiveSupport module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/guides/CHANGELOG.md b/guides/CHANGELOG.md index 70ac22afb41..f85e179b8b9 100644 --- a/guides/CHANGELOG.md +++ b/guides/CHANGELOG.md @@ -1,12 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* No changes. - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Add "back to top" button to guides - - *Alysson Rosa* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/guides/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/guides/CHANGELOG.md) for previous changes. diff --git a/guides/bug_report_templates/active_record_migrations_main.rb b/guides/bug_report_templates/active_record_migrations_main.rb index 5836db3b7e2..49f7272447b 100644 --- a/guides/bug_report_templates/active_record_migrations_main.rb +++ b/guides/bug_report_templates/active_record_migrations_main.rb @@ -28,7 +28,7 @@ end class Payment < ActiveRecord::Base end -class ChangeAmountToAddScale < ActiveRecord::Migration[7.1] +class ChangeAmountToAddScale < ActiveRecord::Migration[7.2] def change reversible do |dir| dir.up do diff --git a/guides/source/7_2_release_notes.md b/guides/source/7_2_release_notes.md new file mode 100644 index 00000000000..98d3a44464f --- /dev/null +++ b/guides/source/7_2_release_notes.md @@ -0,0 +1,88 @@ +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON https://guides.rubyonrails.org.** + +Ruby on Rails 7.2 Release Notes +=============================== + +Highlights in Rails 7.2: + +-------------------------------------------------------------------------------- + +Upgrading to Rails 7.1 +---------------------- + +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 7.1 in case you +haven't and make sure your application still runs as expected before attempting +an update to Rails 7.2. A list of things to watch out for when upgrading is +available in the +[Upgrading Ruby on Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-7-1-to-rails-7-2) +guide. + +Major Features +-------------- + + +Railties +-------- + +Action Cable +------------ + +Action Pack +----------- + +Action View +----------- + +Action Mailer +------------- + +Active Record +------------- + +Active Storage +-------------- + +Active Model +------------ + +Active Support +-------------- + +Active Job +---------- + +Action Text +---------- + +Action Mailbox +---------- + +Ruby on Rails Guides +-------------------- + +Please refer to the [Changelog][guides] for detailed changes. + +### Notable changes + +Credits +------- + +See the +[full list of contributors to Rails](https://contributors.rubyonrails.org/) +for the many people who spent many hours making Rails, the stable and robust +framework it is. Kudos to all of them. + +[railties]: https://github.com/rails/rails/blob/main/railties/CHANGELOG.md +[action-pack]: https://github.com/rails/rails/blob/main/actionpack/CHANGELOG.md +[action-view]: https://github.com/rails/rails/blob/main/actionview/CHANGELOG.md +[action-mailer]: https://github.com/rails/rails/blob/main/actionmailer/CHANGELOG.md +[action-cable]: https://github.com/rails/rails/blob/main/actioncable/CHANGELOG.md +[active-record]: https://github.com/rails/rails/blob/main/activerecord/CHANGELOG.md +[active-storage]: https://github.com/rails/rails/blob/main/activestorage/CHANGELOG.md +[active-model]: https://github.com/rails/rails/blob/main/activemodel/CHANGELOG.md +[active-support]: https://github.com/rails/rails/blob/main/activesupport/CHANGELOG.md +[active-job]: https://github.com/rails/rails/blob/main/activejob/CHANGELOG.md +[action-text]: https://github.com/rails/rails/blob/main/actiontext/CHANGELOG.md +[action-mailbox]: https://github.com/rails/rails/blob/main/actionmailbox/CHANGELOG.md +[guides]: https://github.com/rails/rails/blob/main/guides/CHANGELOG.md diff --git a/guides/source/_welcome.html.erb b/guides/source/_welcome.html.erb index 8325b4cb60a..2a9d5490e73 100644 --- a/guides/source/_welcome.html.erb +++ b/guides/source/_welcome.html.erb @@ -10,12 +10,13 @@

<% else %>

- These are the new guides for Rails 7.1 based on <%= @version %>. + These are the new guides for Rails 7.2 based on <%= @version %>. These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together.

<% end %>

The guides for earlier releases: +Rails 7.1, Rails 7.0, Rails 6.1, Rails 6.0, diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index 8f11320b768..11c7d3b3377 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -410,7 +410,7 @@ in files which are executed against any database that Active Record supports. Here's a migration that creates a new table called `publications`: ```ruby -class CreatePublications < ActiveRecord::Migration[7.1] +class CreatePublications < ActiveRecord::Migration[7.2] def change create_table :publications do |t| t.string :title diff --git a/guides/source/active_record_composite_primary_keys.md b/guides/source/active_record_composite_primary_keys.md index 1bef356d94d..d4e681034b1 100644 --- a/guides/source/active_record_composite_primary_keys.md +++ b/guides/source/active_record_composite_primary_keys.md @@ -36,7 +36,7 @@ You can create a table with a composite primary key by passing the `:primary_key` option to `create_table` with an array value: ```ruby -class CreateProducts < ActiveRecord::Migration[7.1] +class CreateProducts < ActiveRecord::Migration[7.2] def change create_table :products, primary_key: [:store_id, :sku] do |t| t.integer :store_id diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md index a6e39253e79..ad1d353d98c 100644 --- a/guides/source/active_record_migrations.md +++ b/guides/source/active_record_migrations.md @@ -34,7 +34,7 @@ history to the latest version. Active Record will also update your Here's an example of a migration: ```ruby -class CreateProducts < ActiveRecord::Migration[7.1] +class CreateProducts < ActiveRecord::Migration[7.2] def change create_table :products do |t| t.string :name @@ -73,7 +73,7 @@ If you wish for a migration to do something that Active Record doesn't know how to reverse, you can use `reversible`: ```ruby -class ChangeProductsPrice < ActiveRecord::Migration[7.1] +class ChangeProductsPrice < ActiveRecord::Migration[7.2] def change reversible do |direction| change_table :products do |t| @@ -92,7 +92,7 @@ passed to `direction.up` and `direction.down` respectively. Alternatively, you can use `up` and `down` instead of `change`: ```ruby -class ChangeProductsPrice < ActiveRecord::Migration[7.1] +class ChangeProductsPrice < ActiveRecord::Migration[7.2] def up change_table :products do |t| t.change :price, :string @@ -136,7 +136,7 @@ $ bin/rails generate migration AddPartNumberToProducts This will create an appropriately named empty migration: ```ruby -class AddPartNumberToProducts < ActiveRecord::Migration[7.1] +class AddPartNumberToProducts < ActiveRecord::Migration[7.2] def change end end @@ -160,7 +160,7 @@ $ bin/rails generate migration AddPartNumberToProducts part_number:string This will generate the following migration: ```ruby -class AddPartNumberToProducts < ActiveRecord::Migration[7.1] +class AddPartNumberToProducts < ActiveRecord::Migration[7.2] def change add_column :products, :part_number, :string end @@ -176,7 +176,7 @@ $ bin/rails generate migration AddPartNumberToProducts part_number:string:index This will generate the appropriate [`add_column`][] and [`add_index`][] statements: ```ruby -class AddPartNumberToProducts < ActiveRecord::Migration[7.1] +class AddPartNumberToProducts < ActiveRecord::Migration[7.2] def change add_column :products, :part_number, :string add_index :products, :part_number @@ -194,7 +194,7 @@ Will generate a schema migration which adds two additional columns to the `products` table. ```ruby -class AddDetailsToProducts < ActiveRecord::Migration[7.1] +class AddDetailsToProducts < ActiveRecord::Migration[7.2] def change add_column :products, :part_number, :string add_column :products, :price, :decimal @@ -213,7 +213,7 @@ $ bin/rails generate migration RemovePartNumberFromProducts part_number:string This generates the appropriate [`remove_column`][] statements: ```ruby -class RemovePartNumberFromProducts < ActiveRecord::Migration[7.1] +class RemovePartNumberFromProducts < ActiveRecord::Migration[7.2] def change remove_column :products, :part_number, :string end @@ -233,7 +233,7 @@ $ bin/rails generate migration CreateProducts name:string part_number:string generates ```ruby -class CreateProducts < ActiveRecord::Migration[7.1] +class CreateProducts < ActiveRecord::Migration[7.2] def change create_table :products do |t| t.string :name @@ -261,7 +261,7 @@ $ bin/rails generate migration AddUserRefToProducts user:references generates the following [`add_reference`][] call: ```ruby -class AddUserRefToProducts < ActiveRecord::Migration[7.1] +class AddUserRefToProducts < ActiveRecord::Migration[7.2] def change add_reference :products, :user, foreign_key: true end @@ -281,7 +281,7 @@ $ bin/rails generate migration CreateJoinTableCustomerProduct customer product will produce the following migration: ```ruby -class CreateJoinTableCustomerProduct < ActiveRecord::Migration[7.1] +class CreateJoinTableCustomerProduct < ActiveRecord::Migration[7.2] def change create_join_table :customers, :products do |t| # t.index [:customer_id, :product_id] @@ -310,7 +310,7 @@ $ bin/rails generate model Product name:string description:text This will create a migration that looks like this: ```ruby -class CreateProducts < ActiveRecord::Migration[7.1] +class CreateProducts < ActiveRecord::Migration[7.2] def change create_table :products do |t| t.string :name @@ -338,7 +338,7 @@ $ bin/rails generate migration AddDetailsToProducts 'price:decimal{5,2}' supplie will produce a migration that looks like this ```ruby -class AddDetailsToProducts < ActiveRecord::Migration[7.1] +class AddDetailsToProducts < ActiveRecord::Migration[7.2] def change add_column :products, :price, :decimal, precision: 5, scale: 2 add_reference :products, :supplier, polymorphic: true @@ -635,7 +635,7 @@ You can create a table with a composite primary key by passing the `:primary_key` option to `create_table` with an array value: ```ruby -class CreateProducts < ActiveRecord::Migration[7.1] +class CreateProducts < ActiveRecord::Migration[7.2] def change create_table :products, primary_key: [:customer_id, :product_sku] do |t| t.integer :customer_id @@ -744,7 +744,7 @@ reverse. You can use [`reversible`][] to specify what to do when running a migration and what else to do when reverting it. For example: ```ruby -class ExampleMigration < ActiveRecord::Migration[7.1] +class ExampleMigration < ActiveRecord::Migration[7.2] def change create_table :distributors do |t| t.string :zipcode @@ -795,7 +795,7 @@ reverse order they were made in the `up` method. The example in the `reversible` section is equivalent to: ```ruby -class ExampleMigration < ActiveRecord::Migration[7.1] +class ExampleMigration < ActiveRecord::Migration[7.2] def up create_table :distributors do |t| t.string :zipcode @@ -843,7 +843,7 @@ You can use Active Record's ability to rollback migrations using the [`revert`][ ```ruby require_relative "20121212123456_example_migration" -class FixupExampleMigration < ActiveRecord::Migration[7.1] +class FixupExampleMigration < ActiveRecord::Migration[7.2] def change revert ExampleMigration @@ -861,7 +861,7 @@ For example, let's imagine that `ExampleMigration` is committed and it is later decided that a Distributors view is no longer needed. ```ruby -class DontUseDistributorsViewMigration < ActiveRecord::Migration[7.1] +class DontUseDistributorsViewMigration < ActiveRecord::Migration[7.2] def change revert do # copy-pasted code from ExampleMigration @@ -1039,7 +1039,7 @@ Several methods are provided in migrations that allow you to control all this: For example, take the following migration: ```ruby -class CreateProducts < ActiveRecord::Migration[7.1] +class CreateProducts < ActiveRecord::Migration[7.2] def change suppress_messages do create_table :products do |t| @@ -1144,7 +1144,7 @@ When `:ruby` is selected, then the schema is stored in `db/schema.rb`. If you lo at this file you'll find that it looks an awful lot like one very big migration: ```ruby -ActiveRecord::Schema[7.1].define(version: 2008_09_06_171750) do +ActiveRecord::Schema[7.2].define(version: 2008_09_06_171750) do create_table "authors", force: true do |t| t.string "name" t.datetime "created_at" @@ -1229,7 +1229,7 @@ modify data. This is useful in an existing database that can't be destroyed and recreated, such as a production database. ```ruby -class AddInitialProducts < ActiveRecord::Migration[7.1] +class AddInitialProducts < ActiveRecord::Migration[7.2] def up 5.times do |i| Product.create(name: "Product ##{i}", description: "A product.") diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index d40e440ab15..1075b94736d 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -112,7 +112,7 @@ NOTE: `belongs_to` associations _must_ use the singular term. If you used the pl The corresponding migration might look like this: ```ruby -class CreateBooks < ActiveRecord::Migration[7.1] +class CreateBooks < ActiveRecord::Migration[7.2] def change create_table :authors do |t| t.string :name @@ -159,7 +159,7 @@ The main difference from `belongs_to` is that the link column `supplier_id` is l The corresponding migration might look like this: ```ruby -class CreateSuppliers < ActiveRecord::Migration[7.1] +class CreateSuppliers < ActiveRecord::Migration[7.2] def change create_table :suppliers do |t| t.string :name @@ -205,7 +205,7 @@ NOTE: The name of the other model is pluralized when declaring a `has_many` asso The corresponding migration might look like this: ```ruby -class CreateAuthors < ActiveRecord::Migration[7.1] +class CreateAuthors < ActiveRecord::Migration[7.2] def change create_table :authors do |t| t.string :name @@ -257,7 +257,7 @@ end The corresponding migration might look like this: ```ruby -class CreateAppointments < ActiveRecord::Migration[7.1] +class CreateAppointments < ActiveRecord::Migration[7.2] def change create_table :physicians do |t| t.string :name @@ -343,7 +343,7 @@ end The corresponding migration might look like this: ```ruby -class CreateAccountHistories < ActiveRecord::Migration[7.1] +class CreateAccountHistories < ActiveRecord::Migration[7.2] def change create_table :suppliers do |t| t.string :name @@ -386,7 +386,7 @@ end The corresponding migration might look like this: ```ruby -class CreateAssembliesAndParts < ActiveRecord::Migration[7.1] +class CreateAssembliesAndParts < ActiveRecord::Migration[7.2] def change create_table :assemblies do |t| t.string :name @@ -425,7 +425,7 @@ end The corresponding migration might look like this: ```ruby -class CreateSuppliers < ActiveRecord::Migration[7.1] +class CreateSuppliers < ActiveRecord::Migration[7.2] def change create_table :suppliers do |t| t.string :name @@ -510,7 +510,7 @@ Similarly, you can retrieve `@product.pictures`. If you have an instance of the `Picture` model, you can get to its parent via `@picture.imageable`. To make this work, you need to declare both a foreign key column and a type column in the model that declares the polymorphic interface: ```ruby -class CreatePictures < ActiveRecord::Migration[7.1] +class CreatePictures < ActiveRecord::Migration[7.2] def change create_table :pictures do |t| t.string :name @@ -527,7 +527,7 @@ end This migration can be simplified by using the `t.references` form: ```ruby -class CreatePictures < ActiveRecord::Migration[7.1] +class CreatePictures < ActiveRecord::Migration[7.2] def change create_table :pictures do |t| t.string :name @@ -622,7 +622,7 @@ With this setup, you can retrieve `@employee.subordinates` and `@employee.manage In your migrations/schema, you will add a references column to the model itself. ```ruby -class CreateEmployees < ActiveRecord::Migration[7.1] +class CreateEmployees < ActiveRecord::Migration[7.2] def change create_table :employees do |t| t.references :manager, foreign_key: { to_table: :employees } @@ -696,7 +696,7 @@ end This declaration needs to be backed up by a corresponding foreign key column in the books table. For a brand new table, the migration might look something like this: ```ruby -class CreateBooks < ActiveRecord::Migration[7.1] +class CreateBooks < ActiveRecord::Migration[7.2] def change create_table :books do |t| t.datetime :published_at @@ -710,7 +710,7 @@ end Whereas for an existing table, it might look like this: ```ruby -class AddAuthorToBooks < ActiveRecord::Migration[7.1] +class AddAuthorToBooks < ActiveRecord::Migration[7.2] def change add_reference :books, :author end @@ -742,7 +742,7 @@ end These need to be backed up by a migration to create the `assemblies_parts` table. This table should be created without a primary key: ```ruby -class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[7.1] +class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[7.2] def change create_table :assemblies_parts, id: false do |t| t.bigint :assembly_id @@ -760,7 +760,7 @@ We pass `id: false` to `create_table` because that table does not represent a mo For simplicity, you can also use the method `create_join_table`: ```ruby -class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[7.1] +class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[7.2] def change create_join_table :assemblies, :parts do |t| t.index :assembly_id diff --git a/guides/source/command_line.md b/guides/source/command_line.md index ead3642ab9c..5e0493e6e95 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -410,7 +410,7 @@ If you wish to test out some code without changing any data, you can do that by ```bash $ bin/rails console --sandbox -Loading development environment in sandbox (Rails 7.1.0) +Loading development environment in sandbox (Rails 7.2.0) Any modifications you make will be rolled back on exit irb(main):001:0> ``` diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index c31e19ca3b8..0eb985f7fa6 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -614,7 +614,7 @@ To ease the upgrade it's required to add the new default to the value: ```ruby -# new_framework_defaults_7_1.rb.tt +# new_framework_defaults_7_2.rb.tt # Rails.application.config.active_job.existing_behavior = false ``` diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 8c6817ab4d5..64a34893928 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -378,7 +378,7 @@ Processing by PostsController#index as HTML 10| # GET /posts/1 or /posts/1.json 11| def show =>#0 PostsController#index at ~/projects/rails-guide-example/app/controllers/posts_controller.rb:7 - #1 ActionController::BasicImplicitRender#send_action(method="index", args=[]) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.1.0.alpha/lib/action_controller/metal/basic_implicit_render.rb:6 + #1 ActionController::BasicImplicitRender#send_action(method="index", args=[]) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.2.0.alpha/lib/action_controller/metal/basic_implicit_render.rb:6 # and 72 frames (use `bt' command for all frames) (rdbg) ``` @@ -444,14 +444,14 @@ When used without any options, `backtrace` lists all the frames on the stack: ```rb =>#0 PostsController#index at ~/projects/rails-guide-example/app/controllers/posts_controller.rb:7 - #1 ActionController::BasicImplicitRender#send_action(method="index", args=[]) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.1.0.alpha/lib/action_controller/metal/basic_implicit_render.rb:6 - #2 AbstractController::Base#process_action(method_name="index", args=[]) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.1.0.alpha/lib/abstract_controller/base.rb:214 - #3 ActionController::Rendering#process_action(#arg_rest=nil) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.1.0.alpha/lib/action_controller/metal/rendering.rb:53 - #4 block in process_action at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.1.0.alpha/lib/abstract_controller/callbacks.rb:221 - #5 block in run_callbacks at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-7.1.0.alpha/lib/active_support/callbacks.rb:118 - #6 ActionText::Rendering::ClassMethods#with_renderer(renderer=#) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actiontext-7.1.0.alpha/lib/action_text/rendering.rb:20 - #7 block {|controller=#, action=# (4 levels) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actiontext-7.1.0.alpha/lib/action_text/engine.rb:69 - #8 [C] BasicObject#instance_exec at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-7.1.0.alpha/lib/active_support/callbacks.rb:127 + #1 ActionController::BasicImplicitRender#send_action(method="index", args=[]) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-2.0.alpha/lib/action_controller/metal/basic_implicit_render.rb:6 + #2 AbstractController::Base#process_action(method_name="index", args=[]) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.2.0.alpha/lib/abstract_controller/base.rb:214 + #3 ActionController::Rendering#process_action(#arg_rest=nil) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.2.0.alpha/lib/action_controller/metal/rendering.rb:53 + #4 block in process_action at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-7.2.0.alpha/lib/abstract_controller/callbacks.rb:221 + #5 block in run_callbacks at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-7.2.0.alpha/lib/active_support/callbacks.rb:118 + #6 ActionText::Rendering::ClassMethods#with_renderer(renderer=#) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actiontext-7.2.0.alpha/lib/action_text/rendering.rb:20 + #7 block {|controller=#, action=# (4 levels) at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actiontext-7.2.0.alpha/lib/action_text/engine.rb:69 + #8 [C] BasicObject#instance_exec at ~/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-7.2.0.alpha/lib/active_support/callbacks.rb:127 ..... and more ``` diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index b0b583cca20..6f7c4f64a8e 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -331,6 +331,11 @@ description: > This guide provides steps to be followed when you upgrade your applications to a newer version of Ruby on Rails. + - + name: Version 7.2 - ? + url: 7_2_release_notes.html + description: Release notes for Rails 7.1. + work_in_progress: true - name: Version 7.1 - ? url: 7_1_release_notes.html diff --git a/guides/source/maintenance_policy.md b/guides/source/maintenance_policy.md index 3519adc8c16..4d1f87998f9 100644 --- a/guides/source/maintenance_policy.md +++ b/guides/source/maintenance_policy.md @@ -53,7 +53,7 @@ For unsupported series, bug fixes may coincidentally land in a stable branch, but won't be released in an official version. It is recommended to point your application at the stable branch using Git for unsupported versions. -**Currently included series:** `7.1.Z`. +**Currently included series:** `7.2.Z`. Security Issues --------------- @@ -78,7 +78,7 @@ there could be breaking changes in the security release. A security release should only contain the changes needed to ensure the app is secure so that it's easier for applications to remain upgraded. -**Currently included series:** `7.1.Z`, `7.0.Z`, `6.1.Z`. +**Currently included series:** `7.2.Z`, `7.1.Z`. Severe Security Issues ---------------------- @@ -87,7 +87,7 @@ For severe security issues all releases in the current major series, and also th last release in the previous major series will receive patches and new versions. The classification of the security issue is judged by the core team. -**Currently included series:** `7.1.Z`, `7.0.Z`, `6.1.Z`. +**Currently included series:** `7.2.Z`, `7.1.Z`, `7.0.Z`, `6.1.Z`. Unsupported Release Series -------------------------- diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index defd0a5e9e1..20e86e90af4 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -63,7 +63,7 @@ $ bin/rails app:update conflict config/application.rb Overwrite /myapp/config/application.rb? (enter "h" for help) [Ynaqdh] force config/application.rb - create config/initializers/new_framework_defaults_7_0.rb + create config/initializers/new_framework_defaults_7_2.rb ... ``` @@ -75,6 +75,11 @@ The new Rails version might have different configuration defaults than the previ To allow you to upgrade to new defaults one by one, the update task has created a file `config/initializers/new_framework_defaults_X.Y.rb` (with the desired Rails version in the filename). You should enable the new configuration defaults by uncommenting them in the file; this can be done gradually over several deployments. Once your application is ready to run with new defaults, you can remove this file and flip the `config.load_defaults` value. +Upgrading from Rails 7.1 to Rails 7.2 +------------------------------------- + +For more information on changes made to Rails 7.2 please see the [release notes](7_2_release_notes.html). + Upgrading from Rails 7.0 to Rails 7.1 ------------------------------------- diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index f84b350f850..51387a52b16 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,816 +1,2 @@ -## Rails 7.1.0.rc1 (September 27, 2023) ## -* Require `concurrent-ruby` in `config/puma.rb` so that Puma can boot in - production when `WEB_CONCURRENCY` is not explicitly specified. - - Fixes #49323. - - *Matt Brictson* - -* Raise error when generating attribute with dangerous name. - - The following will now raise an error as `save` and `hash` are already - defined by Active Record. - - ```bash - $ bin/rails generate model Post save - $ bin/rails generate model Post hash - ``` - - *Petrik de Heus* - - -## Rails 7.1.0.beta1 (September 13, 2023) ## - -* Add ability to show slow tests to the test runner - - ```bash - $ bin/test --profile # additionally prints 10 (default) slowest tests - # or - $ bin/test --profile 20 # prints 20 slowest tests - ``` - - *fatkodima* - -* `rails new --javascript` generator now supports Bun - - ```bash - $ rails new my_new_app --javascript=bun - ``` - - *Jason Meller* - -* bin/setup uses `bun` instead of `yarn` when generated an app with bun - - Use `bun install` on `bin/setup` when using `bun`. - - *Cadu Ribeiro* - -* `config/application.rb` now includes - - ```ruby - config.autoload_lib(ignore: %w(assets tasks)) - ``` - - In practice, this means that new 7.1 applications autoload from `lib` out of the box. - - *Xavier Noria* - -* Add an option to start rails console in sandbox mode by default - - `sandbox_by_default` option is added to start rails console in sandbox - mode by default. With this option turned on, `--no-sandbox` must be - specified to start rails in non-sandbox mode. - - Note that this option is ignored when rails environment is development - or test. - - *Shouichi Kamiya* - -* Omit `webdrivers` gem dependency from `Gemfile` template - - *Sean Doyle* - -* Support filtering tests by line ranges - - The new syntax allows you to filter tests by line ranges. For example, the - following command runs tests from line 10 to 20. - - ```bash - $ rails test test/models/user_test.rb:10-20 - ``` - - *Shouichi Kamiya*, *Seonggi Yang*, *oljfte*, *Ryohei UEDA* - -* Update default scaffold templates to set 303 (See Other) as status code - on redirect for the update action for XHR requests other than GET or POST - to avoid issues (e.g browsers trying to follow the redirect using the - original request method resulting in double PATCH/PUT) - - *Guillermo Iguaran* - -* The new `config.autoload_lib_once` is similar to `config.autoload_lib`, - except that it adds `lib` to `config.autoload_once_paths` instead. - - By calling `config.autoload_lib_once`, classes and modules in `lib` can be - autoloaded, even from application initializers, but won't be reloaded. - - Please, see further details in the [autoloading - guide](https://guides.rubyonrails.org/v7.1/autoloading_and_reloading_constants.html). - - *Xavier Noria* - -* Add `config.action_dispatch.debug_exception_log_level` to configure the log - level used by `ActionDispatch::DebugExceptions`. - - The default is `:fatal`, but with `load_defaults "7.1"` the default will be - `:error`. - - *Hartley McGuire* - -* Add `DATABASE` option to `railties:install:migrations` - - This allows you to specify which database the migrations should be copied to - when running `rails railties:install:migrations`. - - ```bash - $ rails railties:install:migrations DATABASE=animals - ``` - - *Matthew Hirst* - -* The new method `config.autoload_lib(ignore:)` provides a simple way to - autoload from `lib`: - - ```ruby - # config/application.rb - config.autoload_lib(ignore: %w(assets tasks)) - ``` - - Please, see further details in the [autoloading - guide](https://guides.rubyonrails.org/v7.1/autoloading_and_reloading_constants.html). - - *Xavier Noria* - -* Don't show secret_key_base for `Rails.application.config#inspect`. - - Before: - - ```ruby - Rails.application.config.inspect - "#" - ``` - - After: - - ```ruby - Rails.application.config.inspect - "#" - ``` - - *Petrik de Heus* - -* Deprecate calling `Rails.application.secrets`. - - Rails `secrets` have been deprecated in favor of `credentials`. - Calling `Rails.application.secrets` should show a deprecation warning. - - *Petrik de Heus* - -* Store `secret_key_base` in `Rails.config` for local environments. - - Rails `secrets` have been deprecated in favor of `credentials`. - For the local environments the `secret_key_base` is now stored in - `Rails.config.secret_key_base` instead of the soft deprecated - `Rails.application.secrets.secret_key_base`. - - *Petrik de Heus* - -* Enable force_ssl=true in production by default: Force all access to the app over SSL, - use Strict-Transport-Security, and use secure cookies - - *Justin Searls*, *Aaron Patterson*, *Guillermo Iguaran*, *Vinícius Bispo* - -* Add engine's draw paths to application route set, so that the application - can draw route files defined in engine paths. - - *Gannon McGibbon* - -* Support `VISUAL` environment variable for commands which open an editor, - and prefer it over `EDITOR`. - - *Summer ☀️* - -* Add engine's `test/fixtures` path to `fixture_paths` in `on_load` hook if - path exists and is under the Rails application root. - - *Chris Salzberg* - -* `bin/rails app:template` now runs `bundle install` and any `after_bundle` - blocks after the template is executed. - - *Jonathan Hefner* and *Gerry Caulfield* - -* Enable passing column size to migration generator - - Previously you could pass a limit to the migration generator: - - `rails generate migration CreateAuthor name:text{65535}` - - Now, a size attribute can be passed to the migration generator: - - `rails generate migration CreateAuthor name:text{medium}` - - This generates a migration which includes the size attribute: - - ```ruby - class CreateAuthor < ActiveRecord::Migration[7.1] - def change - create_table :authors do |t| - t.text :name, size: :medium - end - end - end - ``` - - *Josh Broughton*, *Hartley McGuire* - -* Trying to set a config key with the same name of a method now raises: - - ```ruby - config.load_defaults = 7.0 - # NoMethodError: Cannot assign to `load_defaults`, it is a configuration method - ``` - - *Xavier Noria* - -* Deprecate `secrets:edit/show` and remove `secrets:setup` - - `bin/rails secrets:setup` has been deprecated since Rails 5.2 in favor of - credentials. This command has been removed. - - `bin/rails secrets:show` and `bin/rails secrets:edit` have been deprecated - in favor of credentials. - - Run `bin/rails credentials:help` for more information - - *Petrik de Heus* - -* `bin/rails --help` will now list only framework and plugin commands. Rake - tasks defined in `lib/tasks/*.rake` files will no longer be included. For a - list of those tasks, use `rake -T`. - - *Jonathan Hefner* - -* Allow calling `bin/rails restart` outside of app directory. - - The following would previously fail with a "No Rakefile found" error. - - ```bash - $ blog/bin/rails restart - ``` - - *Petrik de Heus* - -* Support prerelease rubies in Gemfile template if RubyGems version is 3.3.13 or higher. - - *Yasuo Honda*, *David Rodríguez* - -* Autoloading setup honors root directories manually set by the user. - - This is relevant for custom namespaces. For example, if you'd like classes - and modules under `app/services` to be defined in the `Services` namespace - without an extra `app/services/services` directory, this is now enough: - - ```ruby - # config/initializers/autoloading.rb - - # The namespace has to exist. - # - # In this example we define the module on the spot. Could also be created - # elsewhere and its definition loaded here with an ordinary `require`. In - # any case, `push_dir` expects a class or module object. - module Services; end - - Rails.autoloaders.main.push_dir("#{Rails.root}/app/services", namespace: Services) - ``` - - Check the autoloading guide for further details. - - *Xavier Noria* - -* Railties now requires the irb gem as a dependency, which means when you install Rails, irb will also - be installed as a gem. Rails will then use the installed version of irb for its console instead of - relying on Ruby's built-in version. - This ensures that Rails has access to the most up-to-date and reliable version of irb for its console. - - *Stan Lo* - -* Use infinitive form for all rails command descriptions verbs. - - *Petrik de Heus* - -* Credentials commands (e.g. `bin/rails credentials:edit`) now respect - `config.credentials.content_path` and `config.credentials.key_path` when set - in `config/application.rb` or `config/environments/#{Rails.env}.rb`. - - Before: - - * `bin/rails credentials:edit` ignored `RAILS_ENV`, and would always edit - `config/credentials.yml.enc`. - - * `bin/rails credentials:edit --environment foo` would create and edit - `config/credentials/foo.yml.enc`. - - * If `config.credentials.content_path` or `config.credentials.key_path` - was set, `bin/rails credentials:edit` could not be used to edit the - credentials. Editing credentials required using `bin/rails - encrypted:edit path/to/credentials --key path/to/key`. - - After: - - * `bin/rails credentials:edit` will edit the credentials file that the app - would load for the current `RAILS_ENV`. - - * `bin/rails credentials:edit` respects `config.credentials.content_path` - and `config.credentials.key_path` when set in `config/application.rb` - or `config/environments/#{Rails.env}.rb`. - - * `bin/rails credentials:edit --environment foo` will create and edit - `config/credentials/foo.yml.enc` _if_ `config.credentials.content_path` - has not been set for the `foo` environment. Ultimately, it will edit - the credentials file that the app would load for the `foo` environment. - - *Jonathan Hefner* - -* Add descriptions for non-Rake commands when running `rails -h`. - - *Petrik de Heus* - -* Show relevant commands when calling help - - When running `rails -h` or just `rails` outside a Rails application, - Rails outputs all options for running the `rails new` command. This can be - confusing to users when they probably want to see the common Rails commands. - - Instead, we should always show the common commands when running `rails -h` - inside or outside a Rails application. - - As the relevant commands inside a Rails application differ from the - commands outside an application, the help USAGE file has been split to - show the most relevant commands for the context. - - *Petrik de Heus* - -* Add Rails::HealthController#show and map it to /up for newly generated applications. - Load balancers and uptime monitors all need a basic endpoint to tell whether the app is up. - This is a good starting point that'll work in many situations. - - *DHH* - -* Only use HostAuthorization middleware if `config.hosts` is not empty - - *Hartley McGuire* - -* Raise an exception when a `before_action`'s "only" or "except" filter - options reference an action that doesn't exist. This will be enabled by - default but can be overridden via config. - - ```ruby - # config/environments/production.rb - config.action_controller.raise_on_missing_callback_actions = false - ``` - - *Jess Bees* - -* Use physical processor count as the default Puma worker count in production. - This can be overridden by setting `ENV["WEB_CONCURRENCY"]` or editing the - generated "config/puma.rb" directly. - - *DHH* - -* Add Docker files by default to new apps: Dockerfile, .dockerignore, bin/docker-entrypoint. - These files can be skipped with `--skip-docker`. They're intended as a starting point for - a production deploy of the application. Not intended for development (see Docked Rails for that). - - Example: - - ```bash - $ docker build -t app . - $ docker volume create app-storage - $ docker run --rm -it -v app-storage:/rails/storage -p 3000:3000 --env RAILS_MASTER_KEY= app - ``` - - You can also start a console or a runner from this image: - - ```bash - $ docker run --rm -it -v app-storage:/rails/storage --env RAILS_MASTER_KEY= app console - ``` - - To create a multi-platform image on Apple Silicon to deploy on AMD or Intel and push to Docker Hub for user/app: - - ```bash - $ docker login -u - $ docker buildx create --use - $ docker buildx build --push --platform=linux/amd64,linux/arm64 -t . - ``` - - *DHH, Sam Ruby* - -* Add ENV["SECRET_KEY_BASE_DUMMY"] for starting production environment with a generated secret base key, - which can be used to run tasks like `assets:precompile` without making the RAILS_MASTER_KEY available - to the build process. - - Dockerfile layer example: - - ``` - RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile - ``` - - *DHH* - -* Show descriptions for all commands in Rails help - - When calling `rails help` most commands missed their description. We now - show the same descriptions as shown in `rails -T`. - - *Petrik de Heus* - -* Always generate the storage/ directory with rails new to ensure there's a stable place to - put permanent files, and a single mount point for containers to map. Then default sqlite3 databases - to live there instead of db/, which is only meant for configuration, not data. - - *DHH* - -* Rails console now disables `IRB`'s autocompletion feature in production by default. - - Setting `IRB_USE_AUTOCOMPLETE=true` can override this default. - - *Stan Lo* - -* Add `config.precompile_filter_parameters`, which enables precompilation of - `config.filter_parameters` using `ActiveSupport::ParameterFilter.precompile_filters`. - Precompilation can improve filtering performance, depending on the quantity - and types of filters. - - `config.precompile_filter_parameters` defaults to `true` for - `config.load_defaults 7.1` and above. - - *Jonathan Hefner* - -* Add `after_routes_loaded` hook to `Rails::Railtie::Configuration` for - engines to add a hook to be called after application routes have been - loaded. - - ```ruby - MyEngine.config.after_routes_loaded do - # code that must happen after routes have been loaded - end - ``` - - *Chris Salzberg* - -* Send 303 See Other status code back for the destroy action on newly generated - scaffold controllers. - - *Tony Drake* - -* Add `Rails.application.deprecators` as a central point to manage deprecators - for an application. - - Individual deprecators can be added and retrieved from the collection: - - ```ruby - Rails.application.deprecators[:my_gem] = ActiveSupport::Deprecation.new("2.0", "MyGem") - Rails.application.deprecators[:other_gem] = ActiveSupport::Deprecation.new("3.0", "OtherGem") - ``` - - And the collection's configuration methods affect all deprecators in the - collection: - - ```ruby - Rails.application.deprecators.debug = true - - Rails.application.deprecators[:my_gem].debug - # => true - Rails.application.deprecators[:other_gem].debug - # => true - ``` - - Additionally, all deprecators in the collection can be silenced for the - duration of a given block: - - ```ruby - Rails.application.deprecators.silence do - Rails.application.deprecators[:my_gem].warn # => silenced (no warning) - Rails.application.deprecators[:other_gem].warn # => silenced (no warning) - end - ``` - - *Jonathan Hefner* - -* Move dbconsole logic to Active Record connection adapter. - - Instead of hosting the connection logic in the command object, the - database adapter should be responsible for connecting to a console session. - This patch moves #find_cmd_and_exec to the adapter and exposes a new API to - lookup the adapter class without instantiating it. - - *Gannon McGibbon*, *Paarth Madan* - -* Add `Rails.application.message_verifiers` as a central point to configure - and create message verifiers for an application. - - This allows applications to, for example, rotate old `secret_key_base` - values: - - ```ruby - config.before_initialize do |app| - app.message_verifiers.rotate(secret_key_base: "old secret_key_base") - end - ``` - - And for libraries to create preconfigured message verifiers: - - ```ruby - ActiveStorage.verifier = Rails.application.message_verifiers["ActiveStorage"] - ``` - - *Jonathan Hefner* - -* Support MySQL's ssl-mode option for the dbconsole command. - - Verifying the identity of the database server requires setting the ssl-mode - option to VERIFY_CA or VERIFY_IDENTITY. This option was previously ignored - for the dbconsole command. - - *Petrik de Heus* - -* Delegate application record generator description to orm hooked generator. - - *Gannon McGibbon* - -* Show BCC recipients when present in Action Mailer previews. - - *Akshay Birajdar* - -* Extend `routes --grep` to also filter routes by matching against path. - - Example: - - ```bash - $ bin/rails routes --grep /cats/1 - Prefix Verb URI Pattern Controller#Action - cat GET /cats/:id(.:format) cats#show - PATCH /cats/:id(.:format) cats#update - PUT /cats/:id(.:format) cats#update - DELETE /cats/:id(.:format) cats#destroy - ``` - - *Orhan Toy* - -* Improve `rails runner` output when given a file path that doesn't exist. - - *Tekin Suleyman* - -* `config.allow_concurrency = false` now use a `Monitor` instead of a `Mutex` - - This allows to enable `config.active_support.executor_around_test_case` even - when `config.allow_concurrency` is disabled. - - *Jean Boussier* - -* Add `routes --unused` option to detect extraneous routes. - - Example: - - ```bash - $ bin/rails routes --unused - - Found 2 unused routes: - - Prefix Verb URI Pattern Controller#Action - one GET /one(.:format) action#one - two GET /two(.:format) action#two - ``` - - *Gannon McGibbon* - -* Add `--parent` option to controller generator to specify parent class of job. - - Example: - - `bin/rails g controller admin/users --parent=admin_controller` generates: - - ```ruby - class Admin::UsersController < AdminController - # ... - end - ``` - - *Gannon McGibbon* - -* In-app custom credentials templates are now supported. When a credentials - file does not exist, `rails credentials:edit` will now try to use - `lib/templates/rails/credentials/credentials.yml.tt` to generate the - credentials file, before falling back to the default template. - - This allows e.g. an open-source Rails app (which would not include encrypted - credentials files in its repo) to include a credentials template, so that - users who install the app will get a custom pre-filled credentials file when - they run `rails credentials:edit`. - - *Jonathan Hefner* - -* Except for `dev` and `test` environments, newly generated per-environment - credentials files (e.g. `config/credentials/production.yml.enc`) now include - a `secret_key_base` for convenience, just as `config/credentials.yml.enc` - does. - - *Jonathan Hefner* - -* `--no-*` options now work with the app generator's `--minimal` option, and - are both comprehensive and precise. For example: - - ```bash - $ rails new my_cool_app --minimal - Based on the specified options, the following options will also be activated: - - --skip-active-job [due to --minimal] - --skip-action-mailer [due to --skip-active-job, --minimal] - --skip-active-storage [due to --skip-active-job, --minimal] - --skip-action-mailbox [due to --skip-active-storage, --minimal] - --skip-action-text [due to --skip-active-storage, --minimal] - --skip-javascript [due to --minimal] - --skip-hotwire [due to --skip-javascript, --minimal] - --skip-action-cable [due to --minimal] - --skip-bootsnap [due to --minimal] - --skip-dev-gems [due to --minimal] - --skip-system-test [due to --minimal] - - ... - - $ rails new my_cool_app --minimal --no-skip-active-storage - Based on the specified options, the following options will also be activated: - - --skip-action-mailer [due to --minimal] - --skip-action-mailbox [due to --minimal] - --skip-action-text [due to --minimal] - --skip-javascript [due to --minimal] - --skip-hotwire [due to --skip-javascript, --minimal] - --skip-action-cable [due to --minimal] - --skip-bootsnap [due to --minimal] - --skip-dev-gems [due to --minimal] - --skip-system-test [due to --minimal] - - ... - ``` - - *Brad Trick* and *Jonathan Hefner* - -* Add `--skip-dev-gems` option to app generator to skip adding development - gems (like `web-console`) to the Gemfile. - - *Brad Trick* - -* Skip Active Storage and Action Mailer if Active Job is skipped. - - *Étienne Barrié* - -* Correctly check if frameworks are disabled when running app:update. - - *Étienne Barrié* and *Paulo Barros* - -* Delegate model generator description to orm hooked generator. - - *Gannon McGibbon* - -* Execute `rails runner` scripts inside the executor. - - Enables error reporting, query cache, etc. - - *Jean Boussier* - -* Avoid booting in development then test for test tasks. - - Running one of the rails test subtasks (e.g. test:system, test:models) would - go through Rake and cause the app to be booted twice. Now all the test:* - subtasks are defined as Thor tasks and directly load the test environment. - - *Étienne Barrié* - -* Deprecate `Rails::Generators::Testing::Behaviour` in favor of `Rails::Generators::Testing::Behavior`. - - *Gannon McGibbon* - -* Allow configuration of logger size for local and test environments - - `config.log_file_size` - - Defaults to `100` megabytes. - - *Bernie Chiu* - -* Enroll new apps in decrypted diffs of credentials by default. This behavior - can be opted out of with the app generator's `--skip-decrypted-diffs` flag. - - *Jonathan Hefner* - -* Support declarative-style test name filters with `bin/rails test`. - - This makes it possible to run a declarative-style test such as: - - ```ruby - class MyTest < ActiveSupport::TestCase - test "does something" do - # ... - end - end - ``` - - Using its declared name: - - ```bash - $ bin/rails test test/my_test.rb -n "does something" - ``` - - Instead of having to specify its expanded method name: - - ```bash - $ bin/rails test test/my_test.rb -n test_does_something - ``` - - *Jonathan Hefner* - -* Add `--js` and `--skip-javascript` options to `rails new` - - `--js` alias to `rails new --javascript ...` - - Same as `-j`, e.g. `rails new --js esbuild ...` - - `--skip-js` alias to `rails new --skip-javascript ...` - - Same as `-J`, e.g. `rails new --skip-js ...` - - *Dorian Marié* - -* Allow relative paths with leading dot slash to be passed to `rails test`. - - Fix `rails test ./test/model/post_test.rb` to run a single test file. - - *Shouichi Kamiya* and *oljfte* - -* Deprecate `config.enable_dependency_loading`. This flag addressed a limitation of the `classic` autoloader and has no effect nowadays. To fix this deprecation, please just delete the reference. - - *Xavier Noria* - -* Define `config.enable_reloading` to be `!config.cache_classes` for a more intuitive name. While `config.enable_reloading` and `config.reloading_enabled?` are preferred from now on, `config.cache_classes` is supported for backwards compatibility. - - *Xavier Noria* - -* Add JavaScript dependencies installation on bin/setup - - Add `yarn install` to bin/setup when using esbuild, webpack, or rollout. - - *Carlos Ribeiro* - -* Use `controller_class_path` in `Rails::Generators::NamedBase#route_url` - - The `route_url` method now returns the correct path when generating - a namespaced controller with a top-level model using `--model-name`. - - Previously, when running this command: - - ```bash - $ bin/rails generate scaffold_controller Admin/Post --model-name Post - ``` - - the comments above the controller action would look like: - - ``` ruby - # GET /posts - def index - @posts = Post.all - end - ``` - - afterwards, they now look like this: - - ``` ruby - # GET /admin/posts - def index - @posts = Post.all - end - ``` - - Fixes #44662. - - *Andrew White* - -* No longer add autoloaded paths to `$LOAD_PATH`. - - This means it won't be possible to load them with a manual `require` call, the class or module can be referenced instead. - - Reducing the size of `$LOAD_PATH` speed-up `require` calls for apps not using `bootsnap`, and reduce the - size of the `bootsnap` cache for the others. - - *Jean Boussier* - -* Remove default `X-Download-Options` header - - This header is currently only used by Internet Explorer which - will be discontinued in 2022 and since Rails 7 does not fully - support Internet Explorer this header should not be a default one. - - *Harun Sabljaković* - -* Add .node-version files for Rails apps that use Node.js - - Node version managers that make use of this file: - https://github.com/shadowspawn/node-version-usage#node-version-file-usage - - The generated Dockerfile will use the same node version. - - *Sam Ruby* - -Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/railties/CHANGELOG.md) for previous changes. +Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/railties/CHANGELOG.md) for previous changes. diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 0db049117ac..beef8821f04 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -329,6 +329,8 @@ module Rails action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor end end + when "7.2" + load_defaults "7.1" else raise "Unknown version #{target_version.to_s.inspect}" end diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb index e640dcd35b4..61a891d6b92 100644 --- a/railties/lib/rails/gem_version.rb +++ b/railties/lib/rails/gem_version.rb @@ -8,9 +8,9 @@ module Rails module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt deleted file mode 100644 index d41af162ad3..00000000000 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +++ /dev/null @@ -1,223 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.1 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.1`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able -# to manually require files that are managed by the autoloader, which you shouldn't do anyway. -# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size -# of the bootsnap cache if you use it. -# Rails.application.config.add_autoload_paths_to_load_path = false - -# Remove the default X-Download-Options headers since it is used only by Internet Explorer. -# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. -# Rails.application.config.action_dispatch.default_headers = { -# "X-Frame-Options" => "SAMEORIGIN", -# "X-XSS-Protection" => "0", -# "X-Content-Type-Options" => "nosniff", -# "X-Permitted-Cross-Domain-Policies" => "none", -# "Referrer-Policy" => "strict-origin-when-cross-origin" -# } - -# Do not treat an `ActionController::Parameters` instance -# as equal to an equivalent `Hash` by default. -# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false - -# Active Record Encryption now uses SHA-256 as its hash digest algorithm. Important: If you have -# data encrypted with previous Rails versions, there are two scenarios to consider: -# -# 1. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default -# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too: -# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1 -# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default -# in 7.0), then you need to configure SHA-256 for Active Record Encryption: -# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256 -# -# If you don't currently have data encrypted with Active Record encryption, you can disable this setting to -# configure the default behavior starting 7.1+: -# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false - -# No longer run after_commit callbacks on the first of multiple Active Record -# instances to save changes to the same database row within a transaction. -# Instead, run these callbacks on the instance most likely to have internal -# state which matches what was committed to the database, typically the last -# instance to save. -# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false - -# Configures SQLite with a strict strings mode, which disables double-quoted string literals. -# -# SQLite has some quirks around double-quoted string literals. -# It first tries to consider double-quoted strings as identifier names, but if they don't exist -# it then considers them as string literals. Because of this, typos can silently go unnoticed. -# For example, it is possible to create an index for a non existing column. -# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. -# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true - -# Disable deprecated singular associations names -# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false - -# Enable the Active Job `BigDecimal` argument serializer, which guarantees -# roundtripping. Without this serializer, some queue adapters may serialize -# `BigDecimal` arguments as simple (non-roundtrippable) strings. -# -# When deploying an application with multiple replicas, old (pre-Rails 7.1) -# replicas will not be able to deserialize `BigDecimal` arguments from this -# serializer. Therefore, this setting should only be enabled after all replicas -# have been successfully upgraded to Rails 7.1. -# Rails.application.config.active_job.use_big_decimal_serializer = true - -# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or -# `write` are given an invalid `expires_at` or `expires_in` time. -# Options are `true`, and `false`. If `false`, the exception will be reported -# as `handled` and logged instead. -# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true - -# Specify whether Query Logs will format tags using the SQLCommenter format -# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. -# Options are `:legacy` and `:sqlcommenter`. -# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter - -# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` -# instances. -# -# The legacy default is `:marshal`, which is a potential vector for -# deserialization attacks in cases where a message signing secret has been -# leaked. -# -# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and -# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing -# with `Marshal` so that legacy messages can still be read. -# -# In Rails 7.2, the default will become `:json` which serializes and -# deserializes with `ActiveSupport::JSON` only. -# -# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`, -# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack` -# can roundtrip some Ruby types that are not supported by JSON, and may provide -# improved performance, but it requires the `msgpack` gem. -# -# For more information, see -# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer -# -# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers -# that have not yet been upgraded must be able to read messages from upgraded -# servers, first deploy without changing the serializer, then set the serializer -# in a subsequent deploy. -# Rails.application.config.active_support.message_serializer = :json_allow_marshal - -# Enable a performance optimization that serializes message data and metadata -# together. This changes the message format, so messages serialized this way -# cannot be read by older versions of Rails. However, messages that use the old -# format can still be read, regardless of whether this optimization is enabled. -# -# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have -# not yet been upgraded must be able to read messages from upgraded servers, -# leave this optimization off on the first deploy, then enable it on a -# subsequent deploy. -# Rails.application.config.active_support.use_message_serializer_for_metadata = true - -# Set the maximum size for Rails log files. -# -# `config.load_defaults 7.1` does not set this value for environments other than -# development and test. -# -# if Rails.env.local? -# Rails.application.config.log_file_size = 100 * 1024 * 1024 -# end - -# Enable raising on assignment to attr_readonly attributes. The previous -# behavior would allow assignment but silently not persist changes to the -# database. -# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true - -# Enable validating only parent-related columns for presence when the parent is mandatory. -# The previous behavior was to validate the presence of the parent record, which performed an extra query -# to get the parent every time the child record was updated, even when parent has not changed. -# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false - -# Enable precompilation of `config.filter_parameters`. Precompilation can -# improve filtering performance, depending on the quantity and types of filters. -# Rails.application.config.precompile_filter_parameters = true - -# Enable before_committed! callbacks on all enrolled records in a transaction. -# The previous behavior was to only run the callbacks on the first copy of a record -# if there were multiple copies of the same record enrolled in the transaction. -# Rails.application.config.active_record.before_committed_on_all_records = true - -# Disable automatic column serialization into YAML. -# To keep the historic behavior, you can set it to `YAML`, however it is -# recommended to explicitly define the serialization method for each column -# rather than to rely on a global default. -# Rails.application.config.active_record.default_column_serializer = nil - -# Enable a performance optimization that serializes Active Record models -# in a faster and more compact way. -# -# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have -# not yet been upgraded must be able to read caches from upgraded servers, -# leave this optimization off on the first deploy, then enable it on a -# subsequent deploy. -# Rails.application.config.active_record.marshalling_format_version = 7.1 - -# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. -# This matches the behaviour of all other callbacks. -# In previous versions of Rails, they ran in the inverse order. -# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true - -# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. -# -# Rails.application.config.active_record.commit_transaction_on_non_local_return = true - -# Controls when to generate a value for has_secure_token declarations. -# -# Rails.application.config.active_record.generate_secure_token_on = :initialize - -# ** Please read carefully, this must be configured in config/application.rb ** -# Change the format of the cache entry. -# Changing this default means that all new cache entries added to the cache -# will have a different format that is not supported by Rails 7.0 -# applications. -# Only change this value after your application is fully deployed to Rails 7.1 -# and you have no plans to rollback. -# When you're ready to change format, add this to `config/application.rb` (NOT -# this file): -# config.active_support.cache_format_version = 7.1 - -# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your -# platform. -# -# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant -# sanitizers if they are supported, else fall back to HTML4 sanitizers. -# -# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. -# -# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor - -# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your -# platform. -# -# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant -# sanitizers if they are supported, else fall back to HTML4 sanitizers. -# -# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. -# -# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor - -# Configure the log level used by the DebugExceptions middleware when logging -# uncaught exceptions during requests -# Rails.application.config.action_dispatch.debug_exception_log_level = :error - -# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 -# parsers. -# -# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4. -# -# In previous versions of Rails, these test helpers always used an HTML4 parser. -# -# Rails.application.config.dom_testing_default_html_version = :html5 diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt new file mode 100644 index 00000000000..fcf2024ecf0 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt @@ -0,0 +1,10 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.2 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.2`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html diff --git a/version.rb b/version.rb index e640dcd35b4..61a891d6b92 100644 --- a/version.rb +++ b/version.rb @@ -8,9 +8,9 @@ module Rails module VERSION MAJOR = 7 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/yarn.lock b/yarn.lock index af5d112bbf6..4b16f80d62a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,24 +29,31 @@ integrity sha512-KE/SxsDqNs3rrWwFHcRh15ZLVFrI0YoZtgAdIyIq9k5hUNmiWRXXThPomIxHuL20sLdgzbDFyvkUMna14bvtrw== "@rails/actioncable@file:/workspaces/rails/actioncable": - version "7.1.0-rc1" + version "7.2.0-alpha" resolved "file:actioncable" "@rails/actiontext@file:/workspaces/rails/actiontext": - version "7.1.0-rc1" + version "7.2.0-alpha" resolved "file:actiontext" dependencies: "@rails/activestorage" ">= 7.1.0-alpha" webpack "^4.17.1" -"@rails/activestorage@>= 7.1.0-alpha", "@rails/activestorage@file:/workspaces/rails/activestorage": - version "7.1.0-rc1" +"@rails/activestorage@>= 7.1.0-alpha": + version "7.1.0-beta1" + resolved "https://registry.npmjs.org/@rails/activestorage/-/activestorage-7.1.0-beta1.tgz" + integrity sha512-5qQ5/65tBOVeFMgGq8F+PhXKrmBLMAnVpyZAe8WsCW5DbINRD8l8ysA8+zBmwCIxBMqn+M9hZoQVjuMPr35bvQ== + dependencies: + spark-md5 "^3.0.1" + +"@rails/activestorage@file:/workspaces/rails/activestorage": + version "7.2.0-alpha" resolved "file:activestorage" dependencies: spark-md5 "^3.0.1" "@rails/ujs@file:/workspaces/rails/actionview": - version "7.1.0-rc1" + version "7.2.0-alpha" resolved "file:actionview" "@rollup/plugin-commonjs@^19.0.1":