Add load hook for ActiveStorage::VariantRecord

Add a load hook called `active_storage_variant_record` (providing `ActiveStorage::VariantRecord`) to allow for overriding aspects of the `ActiveStorage::VariantRecord` class. This makes `ActiveStorage::VariantRecord` consistent with `ActiveStorage::Blob` and `ActiveStorage::Attachment` that already have load hooks.
This commit is contained in:
Brendon Muir 2021-05-28 10:36:16 +12:00
parent fc3e0f9dcf
commit 516ff29584
3 changed files with 10 additions and 0 deletions

View File

@ -1,3 +1,10 @@
* Add a load hook called `active_storage_variant_record` (providing `ActiveStorage::VariantRecord`)
to allow for overriding aspects of the `ActiveStorage::VariantRecord` class. This makes
`ActiveStorage::VariantRecord` consistent with `ActiveStorage::Blob` and `ActiveStorage::Attachment`
that already have load hooks.
*Brendon Muir*
* `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
*Alex Robbin*

View File

@ -6,3 +6,5 @@ class ActiveStorage::VariantRecord < ActiveStorage::Record
belongs_to :blob
has_one_attached :image
end
ActiveSupport.run_load_hooks :active_storage_variant_record, ActiveStorage::VariantRecord

View File

@ -1525,6 +1525,7 @@ These are the load hooks you can use in your own code. To hook into the initiali
| `ActiveJob::TestCase` | `active_job_test_case` |
| `ActiveRecord::Base` | `active_record` |
| `ActiveStorage::Attachment` | `active_storage_attachment` |
| `ActiveStorage::VariantRecord` | `active_storage_variant_record` |
| `ActiveStorage::Blob` | `active_storage_blob` |
| `ActiveStorage::Record` | `active_storage_record` |
| `ActiveSupport::TestCase` | `active_support_test_case` |