Commit Graph

85876 Commits

Author SHA1 Message Date
Jonathan Hefner 26657f5aa6 Fix typos in guides [ci-skip] 2023-01-08 15:42:29 -06:00
Alex Ghiculescu d4fb371c24 [docs] Fix incorrect SQL in Active Record Querying guide
🤦‍♂️ ref: https://github.com/rails/rails/pull/46796#pullrequestreview-1239734996

cc @p8 @lazaronixon
2023-01-08 14:16:45 -07:00
Jean Boussier fe3aca1097
Merge pull request #46923 from fatkodima/fix-grouped-calculations-joins-same-column
Fix ActiveRecord grouped calculations on joined tables on column present in both tables
2023-01-08 20:07:07 +01:00
Petrik de Heus 6897f1413e
Merge pull request #46925 from p8/guides/activerecord-basics-wording
Improve validations wording in Active Record Basics guide [ci-skip]
2023-01-08 12:05:21 +01:00
Petrik 5c8c36d493 Improve validations wording in Active Record Basics guide [ci-skip]
The original contained a long sentence that was a bit awkward. This
shortens the sentence and adds the `create` method as a method that
calls validations.
2023-01-08 10:58:31 +01:00
Yasuo Honda d239e99ea9
Merge pull request #46921 from skipkayhil/fix-incompatible-sidekiq-check
Fix activejob integration test for Sidekiq 6
2023-01-08 09:38:12 +09:00
zzak aea51983da
Merge pull request #46851 from zzak/ar-validations
[Guide] Active Record Validations
2023-01-08 08:44:22 +09:00
zzak 50507abe44
Merge pull request #46856 from zzak/validations-api-default-error-messages
[ci-skip] Document default error messages for some validations
2023-01-08 08:29:52 +09:00
zzak 063299ba20 Run through AR Validations guide 2023-01-08 08:25:12 +09:00
zzak be16195fe1
Merge pull request #46700 from zzak/ar-basics-run
Pass through Active Record Basics guide
2023-01-08 08:21:00 +09:00
zzak 3a690e209c
Merge pull request #46777 from zzak/ar-migrations
Run through Active Record Migrations guide
2023-01-08 08:02:01 +09:00
zzak d8d14da0b9 Run through AR Basics guide 2023-01-08 08:00:48 +09:00
zzak f4048487e0 Run through migrations guide 2023-01-08 07:28:28 +09:00
Petrik de Heus 50fec13b9f
Merge pull request #46924 from p8/guides/improve-grouping
Improve Grouping headings in Active Record Querying guide [ci-skip]
2023-01-07 21:22:44 +01:00
Petrik ecbaea0337 Improve Grouping headings in Active Record Querying guide [ci-skip]
As `GROUP BY` is the actual clause and not `GROUP`, we could rename the
`Group` heading to `Group By`. But as other headings (Ordering, Selecting,
Joining) describe the usage instead of the SQL statement, it has been
renamed to it's usage: `Grouping`.

The `HAVING` condition requires a `GROUP BY` condition, so it's moved
under the `Grouping` section. The heading has been renamed similar to
other headings like `NOT conditions.
2023-01-07 21:20:51 +01:00
fatkodima cf940daa76 Fix ActiveRecord grouped calculations on joined tables on column present in both tables 2023-01-07 21:56:13 +02:00
Hartley McGuire 862dc5b9ca
Fix activejob integration for Sidekiq 6
Sidekiq::MAJOR was added in mperham/sidekiq@b4092e3, which is only
included in 7.0.0+ so we can't use it to check the version for
Sidekiq 6.

Since the test code is written to support both, the condition should
also support both.
2023-01-07 13:45:15 -05:00
Petrik de Heus d7cfaeb152
Merge pull request #46796 from ghiculescu/missing-associated-guide
[docs] Add `where.missing` and `where.associated` to Active Record Querying guide
2023-01-07 19:27:22 +01:00
Jean Boussier 05acc18d73
Merge pull request #46863 from ghiculescu/assert-diffrence-message
Include amount changed by in `assert_difference` failure message
2023-01-07 19:14:15 +01:00
Jean Boussier 15a032517f
Merge pull request #46831 from nick4tech/issue-46741
[issue-46741] remove `require pathname` from `drop` method
2023-01-07 19:05:33 +01:00
Jonathan Hefner 21478c410a
Merge pull request #46919 from skipkayhil/fix-config-host-check-2
Allow setting config.hosts to single IPAddr
2023-01-07 10:53:12 -06:00
Hartley McGuire 27ddfa1045
Allow setting config.hosts to single IPAddr
This was broken in 0019dea and partially fixed for setting config.hosts
to a nil value in 56ecea0.

However, since HostAuthorization coerces the hosts param to an array to
allow a single String or IPAddr as a valid value, the check should do
the same.
2023-01-07 11:23:39 -05:00
Jonathan Hefner 7f2ece8005
Merge pull request #46917 from st0012/fix-hosts-config
Allow setting config.hosts to nil again
2023-01-07 09:30:29 -06:00
Stan Lo 56ecea0d4d
Allow setting config.hosts to nil
Prior to #46858, uses can set `config.hosts = nil` to allow all hosts.
But now it causes `NoMethodError` because the check uses only `empty?`.

Given that the HostAuthorization itself allows taking `nil` as hosts,
I think this breaking change is not intentional. Therefore this commit
fixes the issue by also checking if the value is `nil`.
2023-01-07 14:33:35 +00:00
Jean Boussier 481c169aa5
Merge pull request #46910 from skipkayhil/more-string-include
Fix Performance/StringInclude that RuboCop can't
2023-01-07 14:32:49 +01:00
zzak 131307eca8
Merge pull request #46599 from shouichi/improve-active-storage-guide
Describe env specific ActiveStorage config in the AS guide [skip ci]
2023-01-07 18:44:55 +09:00
Shouichi Kamiya 15b342064a Describe env specific ActiveStorage config in the AS guide [skip ci]
Co-authored-by: zzak <zzakscott@gmail.com>
Co-authored-by: Vipul A M <vipul@hey.com>
Co-authored-by: Ryan <ryan.durel@hey.com>
2023-01-07 17:53:40 +09:00
zzak 6494c8707f
Merge pull request #46190 from soartec-lab/task/add-doc-for-ar-delegated-types
Add guide for `ActiveRecord::DelegatedType` [skip ci]
2023-01-07 17:38:35 +09:00
soartec-lab dceed739c5 Add guide for `ActiveRecord::DelegatedType` [skip ci] 2023-01-07 16:15:40 +09:00
zzak 13fecbd5a9 Use +symbol+ when there is no spaces or other breaking chars for RDoc 2023-01-07 09:23:11 +09:00
zzak 78507d8352 Add changelog for #43487 2023-01-07 09:14:30 +09:00
zzak 911b3a468c Add changelog for #46838 2023-01-07 09:10:41 +09:00
zzak 4d245e0d56 Expand upon changelog for #46817 2023-01-07 09:05:31 +09:00
zzak 72855e5d16
Merge pull request #46909 from p8/guides/activerecord-basics-associations-and-querying
Add Associations section to Active Record basics guide [ci-skip]
2023-01-07 07:33:47 +09:00
zzak 2d8b172fdc
Merge pull request #46913 from p8/guides/actionview-split-template-partials-layouts
Split Templates, Partials and Layouts sections in guide [ci-skip]
2023-01-07 07:32:39 +09:00
zzak 9d984c290b
Merge pull request #46914 from p8/guides/action-controller-overview-rendering
Link to Rendering guide from Action Controller guide[ci-skip]
2023-01-07 07:31:28 +09:00
Petrik 7b6a6f8f48 Link to Rendering guide from Action Controller guide[ci-skip]
The Action Controller Overview guide has a small section about rendering
XML and JSON data, but it doesn't mention HTML rendering or where you
can learn more about rendering.

By making the heading more generic ("Rendering", similar to other
sections like "Cookies", "Parameters", etc) and linking to the Layouts
and Rendering guide, we hopefully make it easier to find information
about rendering.
2023-01-06 22:51:01 +01:00
Petrik de Heus c3763abbc0
Merge pull request #46912 from p8/guides/activerecord-basics-migrations-fix
Move note in Active Record basics guide [ci skip]
2023-01-06 22:32:23 +01:00
Petrik ca6b83f1ec Split Templates, Partials and Layouts sections in guide [ci-skip]
Templates, Partials and Layouts deserve their own sections.
All headings of these section can now be moved a level up, making these
headings show up in the sidebar section. This improves the overview of
what is described in the guide.

Partial Layouts, which already had their own section, is now moved under
the Layouts section, as it is part of the layouts.
2023-01-06 22:30:54 +01:00
Petrik 4e3e4cce66 Move note in Active Record basics guide [ci skip]
Move the paragraph that mentions "above code" under the actual code
block, as this paragraph is more related to that code than the next
paragraph.
2023-01-06 22:16:16 +01:00
Akira Matsuda e0936d99a3
Revert "One less String allocation for event.allocations"
This reverts commit ae569eaef8.

Seems like this broke Action View CI
2023-01-07 06:00:21 +09:00
Petrik 32823ce47b Add Associations section to Active Record basics guide [ci-skip]
The other Active Record guides are mentioned in the Basics guide as
well, so it makes sense to also shortly mention the associations and
where to find out more about them.
2023-01-06 21:59:47 +01:00
Petrik de Heus 10c2b3a3ba
Merge pull request #46911 from p8/guides/activerecord-basics-learn-more
Use a separate paragraph for the "learn more" link in AR basics guide [ci-skip]
2023-01-06 21:57:55 +01:00
Hartley McGuire 583ce94c22
Fix Performance/StringInclude that RuboCop can't
This replaces two instances of /html/.match?(<string>) with the more
performant <string>.include?("html").

Performance/StringInclude was enabled in 3158bbb, however RuboCop does
not flag these two because it is unable to determine that the variable
passed to #match? is a string. In both these cases we know that the
variable must be a string (Mime::Type must be initialized with a string,
and Content-Type must be a string if present per Rack SPEC)

These were found by `rg '/\[\w ]+/\.match\?'`, and while this search
returns other entries they are either comments or in test files.
2023-01-06 15:52:32 -05:00
Petrik b371668f70 Use a separate paragraph for the "learn more" link in guides [ci-skip]
The "learn more" content is a separate subject that seems unrelated to
the previous paragraph. Moving these all to a separate paragraph also
makes the guide more consistent.
2023-01-06 21:51:37 +01:00
Akira Matsuda ae569eaef8
One less String allocation for event.allocations 2023-01-07 04:54:32 +09:00
Alex Ghiculescu 293349c959 Include amount changed by in `assert_difference` failure message
Unless you're very good at math, this test fail message is not the easiest to debug:

```
"User.count" didn't change by 32.
Expected: 1611
  Actual: 1579
```

It's not obvious from the error, but in this case, it actually changed by 0. This is a pretty strong clue as to what went wrong, but the message doesn't tell us that.

This PR improves the message to make debugging easier:

```
"User.count" didn't change by 32 (changed by 0).
Expected: 1611
  Actual: 1579
```
2023-01-06 12:25:34 -07:00
Akira Matsuda 3d00c8b97f
Optimize `camelize` for single word
"hello"
Warming up --------------------------------------
                 old   101.269k i/100ms
                 new   193.263k i/100ms
Calculating -------------------------------------
                 old      1.073M (± 1.0%) i/s -      5.367M in   5.000337s
                 new      1.970M (± 1.0%) i/s -      9.856M in   5.002860s

Comparison:
                 new:  1970358.7 i/s
                 old:  1073491.6 i/s - 1.84x  (± 0.00) slower

"active_record"
Warming up --------------------------------------
                 old    45.864k i/100ms
                 new    44.306k i/100ms
Calculating -------------------------------------
                 old    468.932k (± 1.6%) i/s -      2.385M in   5.087160s
                 new    453.549k (± 1.4%) i/s -      2.304M in   5.080705s

Comparison:
                 old:   468931.7 i/s
                 new:   453549.3 i/s - 1.03x  (± 0.00) slower

"foo_bar_baz/aa_bb_cc"
Warming up --------------------------------------
                 old    18.536k i/100ms
                 new    18.334k i/100ms
Calculating -------------------------------------
                 old    186.371k (± 1.1%) i/s -    945.336k in   5.072959s
                 new    183.743k (± 0.9%) i/s -    935.034k in   5.089229s

Comparison:
                 old:   186371.2 i/s
                 new:   183742.5 i/s - same-ish: difference falls within error
2023-01-07 03:20:56 +09:00
Akira Matsuda 3ade331e75
This has to be mutable now... 2023-01-07 02:17:20 +09:00
Akira Matsuda ca0d6521b1
tags_text() can actually be nil... 2023-01-07 01:59:26 +09:00