-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning of hierarchy class constant already defined #362
Comments
facing the same warning: |
I have the same warnings. ruby: 2.7.1 |
Have the same problem!
ruby: 2.7.2 |
Have the same problem!
ruby: 2.6.6 |
It is probably related to way how hierarchy class is created on the fly closure_tree/lib/closure_tree/support.rb Line 36 in 22bbbf1
and Zeitwerk is not unloading it in rails during reload. @fxn is there anything we can do about to fix this, any idea? |
Hey! I have written a Hello World app following the README. Let's suppose the model is
I believe there are some options depending on use cases:
Does that help? Please, do not hesitate to ask more questions! |
Any updates here? Still get these warnings in development environment, because of how Zeitwerk work ruby: 2.6.1 |
@gambala No, this problem wasn't tackled yet (sadly). Xavier (author of Zeitwerk) pointed out 3 possible solutions. Personally I would go with 1. for now. But I'm not 100% sure this is 100% backwards compatible change. As a proper solution I think this gem should not define hierarchy model on the fly, but let user/generator create model (backed by classic class in file) and just include ℹ️ btw. definition happens here closure_tree/lib/closure_tree/support.rb Line 36 in f3b33f8
|
While this is still open, you can at least avoid the warning if you want. Just depend on Zeitwerk >= 2.5.0, and throw this in an initializer: unless Rails.application.config.cache_classes
# See https://github.com/ClosureTree/closure_tree/issues/362.
Rails.autoloaders.main.on_unload('Tag') do
Object.send(:remove_const, 'TagHierarchy')
end
end |
I'm seeing warnings in the log when reloading a page in development after altering a model that has
closure_tree
added.I've tested this in a new Rails app and confirmed it happens in the latest version of Rails (6.0.2.2).
I haven't noticed any other issues, but it would be nice to remove these warnings.
The text was updated successfully, but these errors were encountered: