You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TLDR: When a gem in the Gemfile has no Railtie defined (dotenv for example), Rails defaults the railtie.root value to the application's root directory. This causes Deface to load the application's root directory as an override path twice when Rails.application.config.cache_classes is false.
This bit of code is to blame:
# check all railties / engines / extensions / application for overrides
app.railties._all.dup.push(app).each do |railtie|
next unless railtie.respond_to? :root
load_overrides(railtie)
end
Appending Rails.application to the list of Railties works fine when no other gems are using the default railtie.root path which is identical to the Rails.application.root path. This results in the overrides being loaded twice, leading to "already initialized constant" warnings when the app boots in development mode (cache_classes = false).
One possible solution would be to append each Railtie root to an array before loading, and return early if the Railtie root already exists in the array. Something like this:
TLDR: When a gem in the
Gemfile
has no Railtie defined (dotenv for example), Rails defaults therailtie.root
value to the application's root directory. This causes Deface to load the application's root directory as an override path twice whenRails.application.config.cache_classes
is false.This bit of code is to blame:
Appending
Rails.application
to the list of Railties works fine when no other gems are using the defaultrailtie.root
path which is identical to theRails.application.root
path. This results in the overrides being loaded twice, leading to "already initialized constant" warnings when the app boots in development mode (cache_classes = false
).One possible solution would be to append each Railtie root to an array before loading, and return early if the Railtie root already exists in the array. Something like this:
The text was updated successfully, but these errors were encountered: