aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/models/active_storage
diff options
context:
space:
mode:
authorEugene Kenny <elkenny@gmail.com>2018-02-25 00:54:27 +0000
committerEugene Kenny <elkenny@gmail.com>2018-02-25 00:54:27 +0000
commiteb834811dc029faa059595e72294d418fb74d0a1 (patch)
tree3f4afdb6d546825aea1e853cbb08a0cb410700d2 /activestorage/app/models/active_storage
parentefd3338b193da5ae5f0d42c4ad792d65e744428c (diff)
downloadrails-eb834811dc029faa059595e72294d418fb74d0a1.tar.gz
rails-eb834811dc029faa059595e72294d418fb74d0a1.tar.bz2
rails-eb834811dc029faa059595e72294d418fb74d0a1.zip
Use lazy load hook to configure ActiveStorage::Blob
`to_prepare` callbacks are run during initialization; using one here meant that `ActiveStorage::Blob` would be loaded when the app boots, which would in turn load `ActiveRecord::Base`. By using a lazy load hook to configure `ActiveStorage::Blob` instead, we can avoid loading `ActiveRecord::Base` unnecessarily.
Diffstat (limited to 'activestorage/app/models/active_storage')
-rw-r--r--activestorage/app/models/active_storage/blob.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb
index 31fbc66965..0cd4ad8128 100644
--- a/activestorage/app/models/active_storage/blob.rb
+++ b/activestorage/app/models/active_storage/blob.rb
@@ -202,4 +202,6 @@ class ActiveStorage::Blob < ActiveRecord::Base
def forcibly_serve_as_binary?
ActiveStorage.content_types_to_serve_as_binary.include?(content_type)
end
+
+ ActiveSupport.run_load_hooks(:active_storage_blob, self)
end