The explanations about avoinding N+1 queries seems out of place early in
the documentation. The actual association hasn't been explained yet and
yet we explain performance optimizations.
It's also confusing when reading the following paragraph where "this
relationship" might seem to refer to the `with_attached_avatar` scope.
Instead we can group it as a performance section together with the
`strict_loading` section.
This makes sure no stale stylesheets and javascript are shown to the
visitors.
This doesn't include images yet.
Co-authored-by: John Athayde <jmpa@meticulous.com>
In addition to PosgreSQL JSON and MySQL JSON data types, developers need to use `store_accessor` instead of `store` when working with SQLite's JSON data type as well.
If a `method_added`/`singleton_method_added` method on a constant doesn't call `super` then none of the `method_added`/`singleton_method_added` methods on ancestors of the constant ever get called by Ruby.
This breaks any code that might want to instrument classes to collect method definition locations, or to do other things when methods are added.
In order to be a good citizen, it is best practice to call `super` from these methods.
- Fix `ActiveRecord::Encryptor#decrypt` documentation
`ActiveRecord::Encryptor#decrypt` documentation mentions that it decrypts a `clean_text`, when, in fact, it decrypts an `encrypted_text`. This commit fixes this issue.
- Add missing `_` on the Active Record Encryption guides
The Custom Key Providers section mentions the expected API for custom key providers. The `decryption_keys` description is missing an underscore character.
Fix: https://github.com/rails/rails/issues/52617
Followup: https://github.com/rails/rails/pull/52622
Previous fixes solved the memory issues, but our fallback implementation
of WeakKeyMap actually have terrible performance, and I can't find a way
to do it in a performent way.
So instead we replace it by a specialized weak map that only accept
Thread or Fiber as keys, and simple purge dead threads on insertion.
This gives us reasonable performance on Ruby 3.1 and 3.2.
* Permit frozen models to be validated
* Remove initialize method since it's not needed
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
Followup: https://github.com/rails/rails/pull/52622
This reference causes connections to linger around longer on Rails CI.
Instead we can simply share an atomic integer to bump the version.
x
Fix: https://github.com/rails/rails/issues/52617
Closes: https://github.com/rails/rails/pull/52618
It isn't per say a leak because the connection reaper eventually prune these,
and also it's not expected that new Threads are constantly making entries into that cache.
But it's true that with Fiber it's probably a bit more common, and the default reaper frequency
isn't adapted to clear this fast enough.
So instead of waiting for the reaper to trigger, which may take a long time, we keep the
caches in IsolatedExcutionState so that when the owning thread or fiber is garbage collected
its cache is too.
However since we need to be able to clear all threads caches, we keep a cache version
on the pool, and bump it to invalidate all caches of a pool at once.
Fix: https://github.com/rails/rails/issues/52601
Now that Active Record connections are fully lazy, just calling
`.lease_connection` isn't actually enough to estalish a connection.
We might as well suggest to use a method with the actual intent.