aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2019-03-28 18:52:02 -0400
committerGeorge Claghorn <george@basecamp.com>2019-03-28 18:52:02 -0400
commitda2c92377c7f36469e56dc25a4ac0604157ac778 (patch)
treebcc2115d61432ac3c0c0bd28f68ae80862e81888
parent562f3a2d21de52872ccd9a2c8b734e30ec63430b (diff)
downloadrails-da2c92377c7f36469e56dc25a4ac0604157ac778.tar.gz
rails-da2c92377c7f36469e56dc25a4ac0604157ac778.tar.bz2
rails-da2c92377c7f36469e56dc25a4ac0604157ac778.zip
Add load hook for ActiveStorage::Attachment
-rw-r--r--activestorage/app/models/active_storage/attachment.rb2
-rw-r--r--activestorage/app/models/active_storage/blob.rb4
-rw-r--r--guides/source/engines.md1
3 files changed, 5 insertions, 2 deletions
diff --git a/activestorage/app/models/active_storage/attachment.rb b/activestorage/app/models/active_storage/attachment.rb
index 13758d9179..874ba80ca8 100644
--- a/activestorage/app/models/active_storage/attachment.rb
+++ b/activestorage/app/models/active_storage/attachment.rb
@@ -46,3 +46,5 @@ class ActiveStorage::Attachment < ActiveRecord::Base
record.attachment_reflections[name]&.options[:dependent]
end
end
+
+ActiveSupport.run_load_hooks :active_storage_attachment, ActiveStorage::Attachment
diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb
index 38757d8f92..c9fbafad1f 100644
--- a/activestorage/app/models/active_storage/blob.rb
+++ b/activestorage/app/models/active_storage/blob.rb
@@ -273,6 +273,6 @@ class ActiveStorage::Blob < ActiveRecord::Base
{ content_type: content_type }
end
end
-
- ActiveSupport.run_load_hooks(:active_storage_blob, self)
end
+
+ActiveSupport.run_load_hooks :active_storage_blob, ActiveStorage::Blob
diff --git a/guides/source/engines.md b/guides/source/engines.md
index a00311bffb..0b17137270 100644
--- a/guides/source/engines.md
+++ b/guides/source/engines.md
@@ -1518,6 +1518,7 @@ To hook into the initialization process of one of the following classes use the
| `ActiveJob::Base` | `active_job` |
| `ActiveJob::TestCase` | `active_job_test_case` |
| `ActiveRecord::Base` | `active_record` |
+| `ActiveStorage::Attachment` | `active_storage_attachment` |
| `ActiveStorage::Blob` | `active_storage_blob` |
| `ActiveSupport::TestCase` | `active_support_test_case` |
| `i18n` | `i18n` |