From 61a3e61e7761bd0a66073f42d986286300cdce6b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 25 Mar 2024 10:19:42 -0300 Subject: [PATCH] Minor text / error message tweaks, fixes, and punctuation Improve a few sentences and add punctuation to some recent changelog & guide entries. [ci skip] --- activerecord/CHANGELOG.md | 14 +++++++------- activerecord/lib/active_record.rb | 2 +- .../lib/active_record/connection_handling.rb | 4 ++-- guides/source/configuring.md | 9 ++++----- .../initializers/new_framework_defaults_7_2.rb.tt | 6 +++--- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index c4f70bc6f91..1a1aaaf7220 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,11 +1,11 @@ -* Allow association's `foreign_key` to be composite +* Allow association's `foreign_key` to be composite. `query_constraints` option was the only way to configure a composite foreign key by passing an `Array`. Now it's possible to pass an Array value as `foreign_key` to achieve the same behavior of an association. *Nikita Vasilevsky* -* Allow association's `primary_key` to be composite +* Allow association's `primary_key` to be composite. Association's `primary_key` can be composite when derived from associated model `primary_key` or `query_constraints`. Now it's possible to explicitly set it as composite on the association. @@ -16,7 +16,7 @@ Controls whether `ActiveRecord::Base.connection` raises an error, emits a deprecation warning, or neither. - `ActiveRecord::Base.connection` checkouts a database connection from the pool and keep it leased until the end of + `ActiveRecord::Base.connection` checkouts a database connection from the pool and keeps it leased until the end of the request or job. This behavior can be undesirable in environments that use many more threads or fibers than there is available connections. @@ -27,7 +27,7 @@ *Jean Boussier* -* Add dirties option to uncached +* Add dirties option to uncached. This adds a `dirties` option to `ActiveRecord::Base.uncached` and `ActiveRecord::ConnectionAdapters::ConnectionPool#uncached`. @@ -39,7 +39,7 @@ *Donal McBreen* -* Deprecate `ActiveRecord::Base.connection` in favor of `.lease_connection` +* Deprecate `ActiveRecord::Base.connection` in favor of `.lease_connection`. The method has been renamed as `lease_connection` to better reflect that the returned connection will be held for the duration of the request or job. @@ -49,14 +49,14 @@ *Jean Boussier* -* Deprecate `ActiveRecord::ConnectionAdapters::ConnectionPool#connection` +* Deprecate `ActiveRecord::ConnectionAdapters::ConnectionPool#connection`. The method has been renamed as `lease_connection` to better reflect that the returned connection will be held for the duration of the request or job. *Jean Boussier* -* Expose a generic fixture accessor for fixture names that may conflict with Minitest +* Expose a generic fixture accessor for fixture names that may conflict with Minitest. ```ruby assert_equal "Ruby on Rails", web_sites(:rubyonrails).name diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index 0eb21096f2d..492eaf6d0fa 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -303,7 +303,7 @@ module ActiveRecord @permanent_connection_checkout = true singleton_class.attr_reader :permanent_connection_checkout - # Defines whether +ActiveRecord::Base.connection+ is allowed, deprecated or entirely disallowed + # Defines whether +ActiveRecord::Base.connection+ is allowed, deprecated, or entirely disallowed. def self.permanent_connection_checkout=(value) unless [true, :deprecated, :disallowed].include?(value) raise ArgumentError, "permanent_connection_checkout must be one of: `true`, `:deprecated` or `:disallowed`" diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index 95c4d065d2f..86b034ce8b8 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -263,13 +263,13 @@ module ActiveRecord case ActiveRecord.permanent_connection_checkout when :deprecated ActiveRecord.deprecator.warn <<~MESSAGE - Called deprecated `ActionRecord::Base.connection`method. + Called deprecated `ActionRecord::Base.connection` method. Either use `with_connection` or `lease_connection`. MESSAGE when :disallowed raise ActiveRecordError, <<~MESSAGE - Called deprecated `ActionRecord::Base.connection`method. + Called deprecated `ActionRecord::Base.connection` method. Either use `with_connection` or `lease_connection`. MESSAGE diff --git a/guides/source/configuring.md b/guides/source/configuring.md index b0dcb1bf019..5eb4dba9ed2 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1054,7 +1054,7 @@ Controls whether migrations are numbered with serial integers or with timestamps #### `config.active_record.automatically_invert_plural_associations` -Controls whether Active Record will automatically look for an inverse relations with a pluralized name. +Controls whether Active Record will automatically look for inverse relations with a pluralized name. Example: @@ -1076,7 +1076,6 @@ it may cause backward compatibility issues with legacy code that doesn't expect This behavior can be disabled on a per-model basis: - ```ruby class Comment < ApplicationRecord self.automatically_invert_plural_associations = false @@ -1089,7 +1088,7 @@ And on a per-association basis: ```ruby class Comment < ApplicationRecord - self.automatically_invert_plural_associations = false + self.automatically_invert_plural_associations = true belongs_to :post, inverse_of: false end @@ -1575,14 +1574,14 @@ record.token # => "fwZcXX6SkJBJRogzMdciS7wf" Controls whether `ActiveRecord::Base.connection` raises an error, emits a deprecation warning, or neither. -`ActiveRecord::Base.connection` checkouts a database connection from the pool and keep it leased until the end of +`ActiveRecord::Base.connection` checkouts a database connection from the pool and keeps it leased until the end of the request or job. This behavior can be undesirable in environments that use many more threads or fibers than there is available connections. This configuration can be used to track down and eliminate code that calls `ActiveRecord::Base.connection` and migrate it to use `ActiveRecord::Base.with_connection` instead. -The value can be set to `:disallowed`, `:deprecated` or `true` to respectively raise an error, emit a deprecation +The value can be set to `:disallowed`, `:deprecated`, or `true` to respectively raise an error, emit a deprecation warning, or neither. | Starting with version | The default value is | 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 index 959991813e1..cdc05f02d4c 100644 --- 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 @@ -29,7 +29,7 @@ # Rails.application.config.active_record.validate_migration_timestamps = true ### -# Controls whether Active Record will automatically look for an inverse relations +# Controls whether Active Record will automatically look for inverse relations # with a pluralized name. # # Example: @@ -37,7 +37,7 @@ # belongs_to :post # end # -# In the above case Active Record will now try to infer a `:comments` relation -# on `Post`, while previously it would only look for `:comment`. +# In this example, Active Record will try to infer a `:comment` (singular) association +# on `Post`. With this option enabled, it will also look for a `:comments` association. #++ # Rails.application.config.active_record.automatically_invert_plural_associations = true