Skip to content

Commit 3cc189c

Browse files
authored
Merge pull request rails#46549 from Earlopain/blob-zeitwerk
Remove ActiveStorage::Blob classic mode gotcha
2 parents f2d1b7b + 1b414d9 commit 3cc189c

File tree

1 file changed

+3
-18
lines changed
  • activestorage/app/models/active_storage

1 file changed

+3
-18
lines changed

activestorage/app/models/active_storage/blob.rb

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,9 @@
1515
# update a blob's metadata on a subsequent pass, but you should not update the key or change the uploaded file.
1616
# If you need to create a derivative or otherwise change the blob, simply create a new blob and purge the old one.
1717
class ActiveStorage::Blob < ActiveStorage::Record
18-
# We use constant paths in the following include calls to avoid a gotcha of
19-
# classic mode: If the parent application defines a top-level Analyzable, for
20-
# example, and ActiveStorage::Blob::Analyzable is not yet loaded, a bare
21-
#
22-
# include Analyzable
23-
#
24-
# would resolve to the top-level one, const_missing would not be triggered,
25-
# and therefore ActiveStorage::Blob::Analyzable would not be autoloaded.
26-
#
27-
# By using qualified names, we ensure const_missing is invoked if needed.
28-
# Please, note that Ruby 2.5 or newer is required, so Object is not checked
29-
# when looking up the ancestors of ActiveStorage::Blob.
30-
#
31-
# Zeitwerk mode does not have this gotcha. If we ever drop classic mode, this
32-
# can be simplified, bare constant names would just work.
33-
include ActiveStorage::Blob::Analyzable
34-
include ActiveStorage::Blob::Identifiable
35-
include ActiveStorage::Blob::Representable
18+
include Analyzable
19+
include Identifiable
20+
include Representable
3621

3722
self.table_name = "active_storage_blobs"
3823

0 commit comments

Comments
 (0)