maniSHarma7575
453577f640
[DOC] Update Active Record basic guide for create method in case of validation fails
2024-07-15 17:35:37 +05:30
John Hawthorn
4867559a10
Merge pull request #52084 from jhawthorn/time_with_zone_always_time
...
Remove dead code for DateTime-backed TimeWithZone
2024-07-11 14:59:00 -07:00
Gannon McGibbon
36b2dbfc1d
Merge pull request #52271 from Schwad/schwad/only_watch_local_translations
...
[i18n] - Do not watch translations from gems when reloading is enabled
2024-07-11 13:00:20 -05:00
John Hawthorn
725ebc9e10
Remove code for DateTime-backed TimeWithZone
...
At one point (I believe until ruby-1.8.0) Time could only represent
values between 1970 and the integer overflow in 2038. On modern Ruby
there does not seem to be a limit.
>> Time.at(2**128)
=> 10783118943836478994022445751222-08-06 01:04:16 -0700
TimeWithZone will also convert a DateTime to a Time when initialized
with one, so the code we had to catch this overflow and to deal with
DateTime is dead. This commit removes this code and adjusts the test to
be more general (the old test passed but we might as well keep a better
version of the test to check that we have a large both negative and
positive range).
Co-authored-by: Adam Hess <HParker@github.com>
2024-07-11 10:34:51 -07:00
Yasuo Honda
86d3ea1089
Merge pull request #52306 from fatkodima/fix-flaky-instrumentation-test
...
Fix a flaky Active Record instrumentation test
2024-07-11 21:33:03 +09:00
Jean Boussier
e98f4d8496
Merge pull request #52305 from joshuay03/fix-52304
...
[Fix #52304 ] Avoid computing `klass` if reflection is a `belongs_to` in `ActiveRecord::AutosaveAssociation#inverse_belongs_to_association_for`
2024-07-11 10:49:36 +02:00
fatkodima
182988b41f
Fix a flaky Active Record instrumentation test
2024-07-11 11:35:27 +03:00
Joshua Young
38c1d5a70b
[ Fix #52304 ] Avoid computing klass
if reflection is a belongs_to
in ActiveRecord::AutosaveAssociation#inverse_belongs_to_association_for
2024-07-11 13:09:07 +05:30
Nick Schwaderer
e617046124
Do not watch translations from gems when reloading is enabled
...
Co-authored-by: Gannon McGibbon <gannon@hey.com>
I18n is intialized with file watchers for all translation paths when
reloading is enabled.
This includes translations contained within gems; which the user will
not be editing in development. This adds unnecessary performance
overhead.
This change ensures we're only watching the files we care about.
```ruby
[
"/Users/schwad/.gem/ruby/3.3.3/gems/validate_url-1.0.15/lib/locale/ar.yml", #
...
"/Users/schwad/path/to/my/app/config/locales/foo/en.yml"
...
]
```
[
"/Users/schwad/path/to/my/app/config/locales/foo/en.yml"
...
]
```
2024-07-11 08:16:21 +01:00
Hartley McGuire
69d904e60f
Merge pull request #49854 from skipkayhil/hm-document-aj-logger
...
Document ActiveJob::Base#logger and #log_arguments
2024-07-11 03:36:53 +00:00
Hartley McGuire
ac916c643a
Document ActiveJob::Base#logger and #log_arguments
2024-07-10 23:14:42 -04:00
Hartley McGuire
8950070e55
Merge pull request #50063 from skipkayhil/hm-doc-metal
...
Add documentation for delegated methods on Metal
2024-07-11 01:58:43 +00:00
Hartley McGuire
eb60e20193
Add documentation for delegated methods on Metal
...
Some of these were specifically mentioned earlier in the Metal docs
(response_body=, content_type=, status=) but were not linked because the
methods were not documented (due to being part of a delegation).
This commit separates all of the delegated methods so that they can be
documented, adds links for the mentioned methods, and additionally
documents two methods on Response that are mentioned in the new Metal
documentation, but were not previously documented.
2024-07-10 21:41:34 -04:00
Eileen M. Uchitelle
99fd4c0c90
Merge pull request #52276 from andycroll/guides-h2-code-css
...
Guides CSS to format code tags in h2 headings [ci skip]
2024-07-10 10:43:26 -04:00
Yasuo Honda
ef087627f5
Merge pull request #52293 from akhilgkrishnan/upgrade-ruby-variant-devcontainer
...
Upgrade devcontainer to use ruby 3.3.4
2024-07-10 07:56:33 +09:00
Akhil G Krishnan
aa10d79bce
Upgrade devcontainer to use ruby 3.3.4
2024-07-09 10:25:16 +05:30
Jean Boussier
16f1222753
Merge pull request #49847 from joshuay03/duplicate-callbacks-when-child-autosaves-parent
...
[Fix #48688 ] Duplicate callback execution when child autosaves parent with `has_one` and `belongs_to`
2024-07-08 19:00:47 +02:00
Jean Boussier
78ce2994b2
Merge pull request #51948 from justinko/issue-51938
...
Restore inferred association class with the same modularized name
2024-07-08 17:53:03 +02:00
Jean Boussier
9e597ea3f7
Merge pull request #52289 from Shopify/fix-strict-freshness
...
Check `If-None-Match` before `If-Modified-Since` with strict freshness
2024-07-08 17:37:25 +02:00
Jenny Shen
bdd9f4e89e
Check If-None-Match before If-Modified-Since with strict freshness
2024-07-08 11:23:00 -04:00
Yasuo Honda
9f178ada79
Merge pull request #52282 from wonda-tea-coffee/delete-obsolete-version-in-compose-yaml
...
Delete obsolete version in compose.yaml
2024-07-08 08:55:20 +09:00
Joshua Young
154f4a4ba9
[Fix 48688] Duplicate callback execution when child autosaves parent with has_one and belongs_to
2024-07-07 11:03:45 +05:30
Jean Boussier
cacf96ecd0
Merge pull request #52283 from natematykiewicz/nate/immutable_cache_forever
...
Make http_cache_forever use `immutable: true`
2024-07-06 20:08:48 +02:00
Jean Boussier
ccdd52427a
Merge pull request #52232 from djfpaagman/activejob-lazy-query-source
...
Improve performance of ActiveJob::LogSubscriber#query_source_location
2024-07-06 20:08:23 +02:00
Dennis Paagman
912440d8b7
Improve performance of ActiveJob::LogSubscriber#enqueue_source_location
...
In line with the improvements made in #49095 , implements the same
lazily yielding backtrace frame. This will improve the performance of
`verbose_enqueue_logs`.
2024-07-06 20:07:21 +02:00
Nate Matykiewicz
78ad54569b
Make http_cache_forever use immutable: true
2024-07-06 01:59:39 -05:00
wonda-tea-coffee
fb69560bea
Delete obsolete version in compose.yaml
...
The following warning appeared when starting devcontainer.
```
WARN[0000] /home/***/ghq/github.com/rails/rails/.devcontainer/compose.yaml: `version` is obsolete
WARN[0000] /tmp/devcontainercli-***/docker-compose/docker-compose.devcontainer.build-1720224621191.yml: `version` is obsolete
```
In fact, the top-level version element will be obsolete in the compose specification.
https://github.com/compose-spec/compose-spec/blob/master/spec.md#version-top-level-element-obsolete
2024-07-06 09:29:11 +09:00
Andy Croll
6fc58b8eea
Guides CSS to format code tags in h2 headings
...
Noticed when reading the edge guides that we have some wonky formatting for the case when we use a method name in an h2 heading.
There's already a fix for h3-level headings, so I copied the font-weight (400) and eyeballed a font-size. 2.25rem looked too much to my eyes, so went with 2rem.
2024-07-05 12:12:12 +01:00
Jean Boussier
0d30e84878
Fix a typo
2024-07-05 11:52:59 +02:00
Petrik de Heus
a9a93368a6
Merge pull request #52275 from kabirpathak/update-doc-for-number-helper-in-active-support
...
[ci skip] Added usage documentation for ActiveSupport::NumberHelper.
2024-07-05 11:34:08 +02:00
Jean Boussier
126445239f
Merge pull request #52274 from Shopify/http-cache
...
Prefer ETag over Last-Modified for `fresh_when` and `stale?` according to the HTTP specification
2024-07-05 10:27:46 +02:00
kabirpathak
126cab3af7
[ci skip] Added usage documentation for ActiveSupport::NumberHelper.
2024-07-05 13:51:55 +05:30
heka1024
fc7637103a
Prefer ETag over Last-Modified for fresh_when
and stale?
according to the HTTP specification
2024-07-05 10:18:43 +02:00
Jean Boussier
c79671cc5c
Merge pull request #52254 from ddux/patch-1
...
[ci skip] Update config/boot.rb contents in initialization.md
2024-07-05 10:00:54 +02:00
Jean Boussier
2edad3c542
Merge pull request #52272 from fatkodima/skip-triggering-instantiation-notification
...
Skip triggering "instantiation.active_record" notification when there are no records
2024-07-05 09:59:55 +02:00
fatkodima
2410312733
Skip triggering "instantiation.active_record" notification when there are no records
2024-07-04 21:43:46 +03:00
eileencodes
4fa56814f1
fix newlines
...
New lines for these were off, only the new options were put on a new
line so the code looked awkward. I'd rather just oneline it.
2024-07-03 08:41:48 -04:00
Eileen M. Uchitelle
71e14aa7e9
Merge pull request #51735 from heka1024/encryption-compressor
...
Introduce `compressor` option to `ActiveRecord::Encryption::Encryptor`
2024-07-03 08:39:13 -04:00
heka1024
75421601ce
Introduce compressor
option to ActiveRecord::Encryption::Encryptor
2024-07-03 18:48:07 +09:00
Xavier Noria
738fde4782
Merge pull request #52251 from rails/fxn/edits
...
Edits in the dev containers guide
2024-07-02 11:00:04 +02:00
Xavier Noria
47a5d067d6
Edits in the dev containers guide
2024-07-02 10:57:00 +02:00
Dakota Dux
e556176457
Update initialization.md
...
The code block that contains the code in`config/boot.rb` is missing the line that requires bootsnap/setup.
2024-07-01 22:46:17 -05:00
Aaron Patterson
35a4946d1c
Merge pull request #52094 from ioquatix/rack-3-streaming
...
Utilize Rack 3 streaming.
2024-07-01 17:39:11 -07:00
Petrik de Heus
599023dc03
Merge pull request #52217 from neanias/neanias/rework-link-text-for-accessibility-in-migrations-guide
...
Replace "here" link titles with meaningful titles [ci skip]
2024-07-01 21:47:33 +02:00
Will Mathewson
3ae8d7b863
Replace "here" link titles with meaningful titles
...
For accessibility reasons[1], it's recommended not to use "here"/"click
here"/"more" as the title for a link. When screen reader users are
tabbing through all links on the page, they'll miss the context of "read
more about X" preceding the "here". Thankfully, the sentences in the are
largely good to go, so the "here" can be dropped in favour of the last
part of the sentence to give the link title more meaning.
Some of these text changes may seem trivial, but when considering the
link text outwith its context sentences, the text has some more meaning
for those reading them through screen readers. (e.g. "API documentation"
-> "`number_to_currency` API documentation")
[1]: https://www.gov.uk/guidance/content-design/links#writing-link-text
2024-07-01 20:05:04 +01:00
Petrik de Heus
ee97ab24fc
Merge pull request #52246 from heka1024/immutable-http-cache-doc [ci-skip]
...
Document `immutable` option in `expires_in`
2024-07-01 21:01:00 +02:00
heka1024
a1a0931e13
Document immutable
option in expires_in
2024-07-02 03:33:21 +09:00
Jean Boussier
d43ee20881
Merge pull request #52234 from kwstannard/indifferent
...
refactor HashWithIndifferentAccess#to_hash
2024-06-30 09:55:26 +02:00
Kelly Wolf Stannard
ed5d646127
Optimize HashWithIndifferentAccess#to_hash
...
Creating a copy by starting from an empty hash and inserting
keys one by one is inneficient because unless the hash is
very small, Ruby will have to reallocate the hash multiple
times until it reaches the same saize as the original.
And every time it happens, keys will have to be re-hashes.
While we're at it, instead of using the generic `convert_value`
we define a dedicated method which saves on needless checks.
Co-Authored-By: Jean Boussier <jean.boussier@gmail.com>
```ruby
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org "
gem "activesupport", path: '.'
gem 'benchmark-ips'
gem 'benchmark-memory'
end
require "active_support"
require "active_support/core_ext/hash/indifferent_access"
require 'benchmark/ips'
module ActiveSupport
class KwstannardHWIA < HashWithIndifferentAccess
def to_hash
Hash[self]
.transform_values! { |v| convert_value(v, conversion: :to_hash) }
.tap { |h| set_defaults(h) }
end
end
class ByrootHWIA < HashWithIndifferentAccess
def to_hash
copy = Hash[self]
copy.transform_values! { |v| convert_value_to_hash(v) }
set_defaults(copy)
copy
end
private
def convert_value_to_hash(value)
if value.is_a? Hash
value.to_hash
elsif value.is_a?(Array)
value.map { |e| convert_value_to_hash(e) }
else
value
end
end
end
end
flat = Hash[(1..9).to_a.product([1])]
flat_baseline = ActiveSupport::HashWithIndifferentAccess.new(flat)
flat_k = ActiveSupport::KwstannardHWIA.new(flat)
flat_b = ActiveSupport::ByrootHWIA.new(flat)
Benchmark.ips do |x|
x.report("original") { flat_baseline.to_hash }
x.report("kwstannard") { flat_k.to_hash }
x.report("byroot") { flat_b.to_hash }
x.compare!(order: :baseline)
end
long_flat = Hash[(1..100).to_a.product([1])]
long_flat_baseline = ActiveSupport::HashWithIndifferentAccess.new(long_flat)
long_flat_k = ActiveSupport::KwstannardHWIA.new(long_flat)
long_flat_b = ActiveSupport::ByrootHWIA.new(long_flat)
Benchmark.ips do |x|
x.report("original") { long_flat_baseline.to_hash }
x.report("kwstannard") { long_flat_k.to_hash }
x.report("byroot") { long_flat_b.to_hash }
x.compare!(order: :baseline)
end
deep_baseline = ActiveSupport::HashWithIndifferentAccess.new(flat.dup)
3.times.reduce(deep_baseline) { |deep, _| deep[:deep] = ActiveSupport::HashWithIndifferentAccess.new(flat.dup) }
deep_k = ActiveSupport::KwstannardHWIA.new(flat.dup)
3.times.reduce(deep_k) { |deep, _| deep[:deep] = ActiveSupport::KwstannardHWIA.new(flat.dup) }
deep_b = ActiveSupport::ByrootHWIA.new(flat.dup)
3.times.reduce(deep_b) { |deep, _| deep[:deep] = ActiveSupport::ByrootHWIA.new(flat.dup) }
Benchmark.ips do |x|
x.report("original") { deep_baseline.to_hash }
x.report("kwstannard") { deep_k.to_hash }
x.report("byroot") { deep_b.to_hash }
x.compare!(order: :baseline)
end
```
```
$ ruby /tmp/to_hash.rb
Fetching gem metadata from https://rubygems.org/ ..........
Resolving dependencies...
ruby 3.3.1 (2024-04-23 revision c56cd86388) [arm64-darwin23]
Warming up --------------------------------------
original 92.830k i/100ms
kwstannard 125.443k i/100ms
byroot 139.810k i/100ms
Calculating -------------------------------------
original 968.200k (± 2.9%) i/s - 4.920M in 5.086600s
kwstannard 1.268M (± 2.9%) i/s - 6.398M in 5.049545s
byroot 1.397M (± 2.9%) i/s - 6.990M in 5.008404s
Comparison:
original: 968200.3 i/s
byroot: 1397069.4 i/s - 1.44x faster
kwstannard: 1268207.5 i/s - 1.31x faster
ruby 3.3.1 (2024-04-23 revision c56cd86388) [arm64-darwin23]
Warming up --------------------------------------
original 11.051k i/100ms
kwstannard 15.865k i/100ms
byroot 17.778k i/100ms
Calculating -------------------------------------
original 109.059k (± 5.1%) i/s - 552.550k in 5.082820s
kwstannard 157.499k (± 7.4%) i/s - 793.250k in 5.072103s
byroot 177.066k (± 7.2%) i/s - 888.900k in 5.052601s
Comparison:
original: 109059.1 i/s
byroot: 177065.9 i/s - 1.62x faster
kwstannard: 157499.0 i/s - 1.44x faster
ruby 3.3.1 (2024-04-23 revision c56cd86388) [arm64-darwin23]
Warming up --------------------------------------
original 22.249k i/100ms
kwstannard 30.132k i/100ms
byroot 34.116k i/100ms
Calculating -------------------------------------
original 224.127k (± 1.7%) i/s - 1.135M in 5.064253s
kwstannard 295.912k (± 5.9%) i/s - 1.476M in 5.007324s
byroot 343.225k (± 1.7%) i/s - 1.740M in 5.070715s
Comparison:
original: 224127.0 i/s
byroot: 343224.6 i/s - 1.53x faster
kwstannard: 295912.4 i/s - 1.32x faster
```
2024-06-30 09:33:55 +02:00
Ryuta Kamizono
88924dd9d4
Merge pull request #52236 from takmar/fix-broken-link-in-dev-containers-guide
...
Fix broken links in Dev Containers start guide [ci skip]
2024-06-29 23:26:31 +09:00