Commit Graph

88657 Commits

Author SHA1 Message Date
Ian Candy
eae26caec3 Clarify deprecation warning for alias_attribute
We ran into a few cases at GitHub where we were using alias_attribute
incorrectly and the new behavior either didn't warn or raised an unclear
deprecation warning. This attempts to add clarity to the deprecation reason
when you try to alias something that isn't actually an attribute.

Previously, trying to alias a generated attribute method, such as `attribute_in_database`, would
still hit `define_proxy_call`, because we were only checking the owner of the target method.

In the future, we should probably raise if you try to use alias_attribute for a non-attribute.

Note that we don't raise the warning for abstract classes, because the attribute may be implemented
by a child class. We could potentially figure out a way to raise in these cases as well, but this
hopefully is good enough for now.

Finally, I also updated the way we're setting `local_alias_attributes` when `alias_attribute` is
first called. This was causing problems since we now use `alias_attribute` early in the
`load_schema!` call for some models: https://buildkite.com/rails/rails/builds/98910
2023-08-30 13:19:58 -04:00
Adrianna Chang
45a037e91e
Merge pull request #49073 from akhilgkrishnan/deprecators_method_release_note
[skip ci] Rails.application.deprecators description added for rails 7.1 release note
2023-08-30 10:58:21 -04:00
Akhil G Krishnan
b52c9e04dc Rails.application.deprecators description added for rails 7.1 release note
minor fix

Request changes updated

review changes updated
2023-08-30 20:00:12 +05:30
Rafael Mendonça França
4a9974acfa
Merge pull request #49081 from mattbrictson/fix-libxml-ruby-comment
Remove outdated libxml-ruby version spec in XmlMini doc comment
2023-08-29 17:58:38 -04:00
Matt Brictson
0bbaaf69ad
Remove outdated libxml-ruby version spec in XmlMini doc comment
XmlMini is currently being tested against libxml-ruby 4.0.0[^1], but the
doc comment for XmlMini says:

```
To use the much faster libxml parser:
gem 'libxml-ruby', '=0.9.7'
```

This comment seems to be very much out of date and could mislead users.

Fix by removing the version specifier so that the documentation simply
recommends:

```
To use the much faster libxml parser:
gem 'libxml-ruby'
XmlMini.backend = 'LibXML'
```

[^1]: 621bc68548/Gemfile.lock (L310)
2023-08-29 13:45:42 -07:00
Eileen M. Uchitelle
621bc68548
Merge pull request #49080 from gmcgibbon/generate_correct_cpk_param
Fix to_param id generation for partial composite keys
2023-08-29 15:16:27 -04:00
Gannon McGibbon
a7cc807cb9 Fix to_param parameter generation for partial composite keys
Adds tests for url_for use with composite primary key models. Fixes bug
related to new CPK model to_param generation.
2023-08-29 14:04:03 -05:00
Adrianna Chang
9d8ac620af
Merge pull request #49059 from deepakmahakale/release_notes_7_1/activerecord_normalizes
[skip ci] Add ActiveRecord::Base.normalizes to 7.1 release notes
2023-08-29 11:05:50 -04:00
Adrianna Chang
684a2a278f
Merge pull request #49074 from akhilgkrishnan/activestorage-notable-release-note
[skip ci] ActiveStorage notable changes added to 7.1 release note
2023-08-29 11:02:07 -04:00
Adrianna Chang
5ff6a97381
Merge pull request #49076 from akhilgkrishnan/actionpack-notable-release-note
[skip ci] Railties, ActionPack notable changes and deprecations added to 7.1 release note
2023-08-29 11:01:20 -04:00
Deepak Mahakale
53a44b98b6 [skip ci] Add ActiveRecord::Base.normalizes to 7.1 release notes
Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
2023-08-29 20:31:14 +05:30
Akhil G Krishnan
19cb350296 [skip ci] ActiveStorage notable changes added to 7.1 release note
Request changes updated
2023-08-29 20:27:35 +05:30
Akhil G Krishnan
c0ee485db8 [skip ci] ActionPack notable changes and deprecations added to 7.1 release note
Request changes updated
2023-08-29 20:24:13 +05:30
Adrianna Chang
27c5c7cd99
Merge pull request #48920 from fidalgo/fidalgo/update-assert_enqueued_with-documentation
[docs] Update assert_enqueued_with documentation with keyword arguments example
2023-08-29 10:36:22 -04:00
Adrianna Chang
72b356cdf5
Merge pull request #49061 from deepakmahakale/release_notes_7_1/removals_for_actionmailer
[skip ci] Add deprecations/removals for action-mailer, active-storage and active-job
2023-08-29 10:08:53 -04:00
Eileen M. Uchitelle
b1f0efebfe
Merge pull request #49069 from gmcgibbon/generate_correct_cpk_form_ids
Fix form_for id generation for new CPK models
2023-08-29 09:29:11 -04:00
Petrik de Heus
4f33e65fc5
Merge pull request #49071 from HParker/backfill-relation-batching-changelog
Add changelog entry for batching using loaded relations
2023-08-29 10:22:31 +02:00
Xavier Noria
2bc9e8c3e0
Merge pull request #49054 from akhilgkrishnan/autoload_lib_release_note
[skip ci] config.autoload_lib method description added in 7.1 release note
2023-08-29 10:05:01 +02:00
Akhil G Krishnan
6b507f87e3 method description added in 7.1 release note
Review changes updated
2023-08-29 12:22:03 +05:30
Deepak Mahakale
8c4e216ab0 [skip ci] Add deprecations/removals for action-mailer, active-storage and active-job to 7.1 release notes 2023-08-29 10:17:13 +05:30
HParker
451053eca5 Add changelog entry for batching using loaded relations
This backfills a changelog entry for PR #48876. This is potentially something Rails users
should be aware of as in very specific situations it can be a change in behavior
2023-08-28 17:29:52 -07:00
Gannon McGibbon
7ea19698b0 Fix form_for id generation for new CPK models
Adds tests for form_for use with composite primary key models. Fixes bug
related to new CPK model dom id generation.
2023-08-28 15:56:25 -05:00
Jean Boussier
735cba5bed
Merge pull request #49063 from gregmolnar/upsert 2023-08-28 19:31:44 +02:00
Greg Molnar
c775fa4db5 upsert should accept update_only parameter like upsert_all does 2023-08-28 16:59:24 +00:00
Rafael Mendonça França
a2a520e733
Merge pull request #49057 from akhilgkrishnan/action_cable_release_note
[skip ci] ActionCable notable changes added to 7.1 release note
2023-08-28 12:55:30 -04:00
Rafael Mendonça França
0b1f33e684
Merge pull request #49035 from akhilgkrishnan/action_mailer_release_note
[skip ci] Added ActionMailer notable features and deprecations to 7.1 release note
2023-08-28 12:53:10 -04:00
Rafael Mendonça França
fcda3a8857
Merge pull request #49034 from akhilgkrishnan/perform_all_later_to_relase_note_7_1
[skip ci] Add description for perform_all_later method in 7.1 release note
2023-08-28 12:47:49 -04:00
Rafael Mendonça França
4aa1625edd
Always install sdoc from git
The EDGE environment variable isn't set when installing the gems.
Since this branch is the edge branch, we don't need this environment
variable.
2023-08-28 15:29:58 +00:00
Eileen M. Uchitelle
743d1fc71c
Merge pull request #49042 from Shopify/add-parameters-extract-method
Add `extract_value` method to `ActionController::Parameters`
2023-08-28 11:09:55 -04:00
Ryuta Kamizono
0d46f69db5
Merge pull request #49058 from tiramizoo/kamal
Rename MRSK to Kamal

[ci-skip]
2023-08-28 16:48:12 +09:00
Wojciech Wnętrzak
b872b36e0c
Rename MRSK to Kamal
https://github.com/basecamp/kamal/releases/tag/v0.16.0

[ci skip]
2023-08-28 09:42:15 +02:00
Akhil G Krishnan
3228f6421f [skip ci] ActionCable notable changes added to 7.1 release note 2023-08-28 12:24:35 +05:30
Yasuo Honda
80592d6dc6
Merge pull request #49048 from zzak/debug/sqlite3/1.6.4 2023-08-27 17:51:17 +09:00
zzak
0f580a20fe
Try to build with sqlite3 1.6.3 2023-08-27 09:29:29 +09:00
Jean Boussier
55412cd925
Merge pull request #49040 from paulreece/select_hash_sql_fix
Improve #select with Hash argument to be more consistent with #where
2023-08-26 11:34:43 +02:00
Nikita Vasilevsky
da7a6da4e7
Add extract_value method to ActionController::Parameters
This commit adds `extract_value` method to `ActionController::Parameters`
as a primary way to extract composite `id` values serialized from
`ActiveRecord::Base#to_param` called on a model with a composite primary key.
2023-08-25 22:34:10 +00:00
paulreece
4026aba1f1 This branch fixes the issues raised in #48862. By adding the key and it's values to self.references_values as Rails does when building a where clause, it prevents unneccessary aliasing from taking place and allows a User to successfully use a table_alias in their select query using a Hash. 2023-08-25 17:53:59 -04:00
Dave Aronson
f6b987d521
Replace repeated list literals in Getting Started guide w/ a constant (#49007)
* Replace list literals w/ Visible::VALID_STATUSES

In Getting Started guide, in the article and comment status dropdowns, use Visible::VALID_STATUSES instead of repeating the list of valid statuses.  This makes the code DRYer and more expressive.  This PR also adds a comment to that effect.

* Remove text changes, leave just code

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2023-08-25 17:14:08 -04:00
Rafael Mendonça França
fb48025d2f
Merge pull request #49039 from koic/add_bigdecimal_to_runtime_dependency
Add bigdecimal to runtime dependency
2023-08-25 17:06:07 -04:00
Koichi ITO
a77535c74c Add bigdecimal to runtime dependency
## Motivation / Background

Follow up 1c93288f8b.

This PR adds bigdecimal to runtime dependency of Active Support to suppress the following Ruby 3.3.0dev's warning.

> /Users/koic/.rbenv/versions/3.3.0-dev/lib/ruby/gems/3.3.0+0/bundler/gems/rails-a8871e6829e5/activesupport/lib/
> active_support/core_ext/object/json.rb:5: warning: bigdecimal will be not part of the default gems since Ruby 3.4.0.
> Add bigdecimal to your Gemfile. Also contact author of  to add bigdecimal into its gemspec.

The grep yields the following results:

```console
$ git grep 'require.*bigdecimal'
activejob/lib/active_job/arguments.rb:3:require "bigdecimal"
activejob/lib/active_job/serializers/big_decimal_serializer.rb:3:require "bigdecimal"
activejob/test/cases/argument_serialization_test.rb:3:require "bigdecimal"
activemodel/lib/active_model/type/decimal.rb:3:require "bigdecimal/util"
activemodel/lib/active_model/validations/numericality.rb:5:require "bigdecimal/util"
activemodel/test/cases/validations/numericality_validation_test.rb:8:require "bigdecimal"
activerecord/test/cases/adapters/sqlite3/quoting_test.rb:4:require "bigdecimal"
activerecord/test/cases/arel/visitors/to_sql_test.rb:4:require "bigdecimal"
activerecord/test/cases/migration_test.rb:5:require "bigdecimal/util"
activesupport/lib/active_support/core_ext/big_decimal/conversions.rb:3:require "bigdecimal"
activesupport/lib/active_support/core_ext/big_decimal/conversions.rb:4:require "bigdecimal/util"
activesupport/lib/active_support/core_ext/object/json.rb:5:require "bigdecimal"
activesupport/lib/active_support/message_pack/extensions.rb:3:require "bigdecimal"
activesupport/lib/active_support/xml_mini.rb:5:require "bigdecimal"
activesupport/lib/active_support/xml_mini.rb:6:require "bigdecimal/util"
activesupport/test/core_ext/hash_ext_test.rb:4:require "bigdecimal"
activesupport/test/core_ext/object/duplicable_test.rb:4:require "bigdecimal"
activesupport/test/hash_with_indifferent_access_test.rb:4:require "bigdecimal"
activesupport/test/json/encoding_test_cases.rb:3:require "bigdecimal"
```

By adding only to Active Support as a dependency, it should resolve the issue due to the dependency.

## Detail

The warning is confirmed in the following step:

```ruby
$ cat generic_main.rb
# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", github: "rails/rails", branch: "main"
end

require 'active_support'
require 'minitest/autorun'
# These gems will be bundled gems in Ruby 3.4
require 'bigdecimal'
```

Run generic_main.rb with Ruby 3.3.0dev below.

```console
$ ruby -v
ruby 3.3.0dev (2023-08-25T17:47:04Z master 7d32011399) [x86_64-darwin22]

$ ruby generic_main.rb
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
/Users/koic/.rbenv/versions/3.3.0-dev/lib/ruby/gems/3.3.0+0/bundler/gems/rails-a8871e6829e5/activesupport/lib/
active_support/core_ext/object/json.rb:5: warning: bigdecimal will be not part of the default gems since Ruby 3.4.0.
Add bigdecimal to your Gemfile. Also contact author of  to add bigdecimal into its gemspec.
Run options: --seed 39015

# Running:

Finished in 0.001313s, 0.0000 runs/s, 0.0000 assertions/s.
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
```

## Additional information

It is essentially the same as https://github.com/rails/rails/pull/48907.
2023-08-26 03:40:25 +09:00
Jean Boussier
a8871e6829
Merge pull request #49037 from etiennebarrie/fix-test-leak
Fix test leak
2023-08-25 18:16:38 +02:00
Étienne Barrié
0810752188 Use Object#with 2023-08-25 17:06:14 +02:00
Étienne Barrié
7e11402e72 Fix test leak 2023-08-25 17:01:22 +02:00
Akhil G Krishnan
c95796489a Added ActionMailer notable features and deprecations to 7.1 release note
Unwanted changes
2023-08-25 17:56:09 +05:30
Akhil G Krishnan
26931def8c Add description for perform_all_later method in 7.1 release note 2023-08-25 16:43:00 +05:30
Xavier Noria
153eae8995
Merge pull request #49032 from rails/gen-config.autoload_lib
Generate config.autoload_lib(...) for new apps
2023-08-25 09:36:44 +02:00
Xavier Noria
b16adcd4e4 Generate config.autoload_lib(...) for new apps 2023-08-25 09:22:25 +02:00
Yasuo Honda
20af938f39
Merge pull request #49031 from yahonda/cache_format_version_7_1_for_railtie_test
Configure `config.active_support.cache_format_version = 7.1` for `RailtieTest`
2023-08-25 13:32:15 +09:00
Yasuo Honda
2ab10fac93 Configure config.active_support.cache_format_version = 7.1 for RailtieTest
This commit suppresses the `DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1`
has been deprecated and will be removed in Rails 7.2.` warning at `RailtieTest`

This commit sets `config.active_support.cache_format_version = 7.1` explicitly for `RailtieTest`
because https://github.com/rails/rails/pull/48598 deprecates `active_support.cache_format_version = 6.1` and still the default format_version is 6.1, I think this is intended.

4ac237de74/activesupport/lib/active_support/cache.rb (L55)

```
    @format_version = 6.1
```

\### Steps to reproduce
```
git clone https://github.com/rails/rails
cd rails/activemodel
bundle
bin/test test/cases/railtie_test.rb:21
```

\### Without this commit
```
$ bin/test test/cases/railtie_test.rb:21
Run options: --seed 36872

\# Running:

DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.

Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
for more information on how to upgrade.
 (called from block (3 levels) in run at /home/yahonda/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/minitest-5.19.0/lib/minitest/test.rb:94)
.

Finished in 0.321429s, 3.1111 runs/s, 3.1111 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
$
```

\### With this commit
```
$ bin/test test/cases/railtie_test.rb:21
Run options: --seed 65282

\# Running:

Finished in 0.006108s, 0.0000 runs/s, 0.0000 assertions/s.
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
$
```
2023-08-25 12:48:39 +09:00
Dave Aronson
4ac237de74
select existing article status if any, in Getting Started Guide -- Fixes #45028 (mostly) (#49010)
* select existing article status if any

In the Getting Started guide, in the dropdown for an article or comment's status, pre-selecting `public` will make _all_ articles seem `public` even if their status is really something else -- even `nil`.  This was reported in issue #45028.  Selecting `article.status || 'public'` instead will fix this, in _most_ cases.  Pre-existing articles with `nil` status will show up as `public`, but if the form is submitted, they will indeed become `public`.

This commit makes that change, and adds text to explain why it is done.

* Simplify wording of changes to Getting Started

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2023-08-24 17:31:46 -04:00