Skip to content
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

Fails with wrong class_name: "NameError: NameError: uninitialized constant" #182

Open
frsantos opened this issue Aug 9, 2024 · 1 comment

Comments

@frsantos
Copy link

frsantos commented Aug 9, 2024

Hi!, thank you for the gem.

We are currently evaluating it, but it fails with the following case: we had a relation defined with a wrong class_name, as the model was removed but we didn't remove the associated has_many:

has_many :logbooks_assets_images, class_name: '::Assets::Image'

Running the gem it raises and stops processing instead of reporting an issue:

NameError: uninitialized constant ::Assets::Image
/usr/local/bundle/gems/activesupport-6.0.5.1/lib/active_support/inflector/methods.rb:284:in `const_get'
/usr/local/bundle/gems/activesupport-6.0.5.1/lib/active_support/inflector/methods.rb:284:in `block in constantize'
/usr/local/bundle/gems/activesupport-6.0.5.1/lib/active_support/inflector/methods.rb:280:in `each'
/usr/local/bundle/gems/activesupport-6.0.5.1/lib/active_support/inflector/methods.rb:280:in `inject'
/usr/local/bundle/gems/activesupport-6.0.5.1/lib/active_support/inflector/methods.rb:280:in `constantize'
/usr/local/bundle/gems/activesupport-6.0.5.1/lib/active_support/dependencies/zeitwerk_integration.rb:19:in `constantize'
/usr/local/bundle/gems/activerecord-6.0.5.1/lib/active_record/inheritance.rb:185:in `compute_type'
/usr/local/bundle/gems/activerecord-6.0.5.1/lib/active_record/reflection.rb:423:in `compute_class'
/usr/local/bundle/gems/activerecord-6.0.5.1/lib/active_record/reflection.rb:380:in `klass'
/usr/local/bundle/gems/active_record_doctor-1.14.0/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:90:in `block (2 levels) in detect'
/usr/local/bundle/gems/active_record_doctor-1.14.0/lib/active_record_doctor/detectors/base.rb:318:in `block (3 levels) in each_association'
/usr/local/bundle/gems/active_record_doctor-1.14.0/lib/active_record_doctor/logger/dummy.rb:7:in `log'
/usr/local/bundle/gems/active_record_doctor-1.14.0/lib/active_record_doctor/detectors/base.rb:96:in `log'
@fatkodima
Copy link
Contributor

Basically same as #181.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants