Closed barnaclebarnes closed 2 years ago
Thank you for opening the issue, @barnaclebarnes. I added support for polymorphic associations so expect to see an update later today.
@gregnavis Thanks for that. I just pulled down master and it is now crashing on a different error. I have this:
class Map < ApplicationRecord
has_many :screen_section_locations, inverse_of: :map
end
class StorySectionLocation < ApplicationRecord
belongs_to :map, inverse_of: :screen_section_locations, optional: true
end
And this is causing this on when processing the Map
model:
NameError: uninitialized constant Map::ScreenSectionLocation
/usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/inheritance.rb:237:in `compute_type'
/usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/reflection.rb:409:in `compute_class'
/usr/local/bundle/gems/activerecord-6.1.4.7/lib/active_record/reflection.rb:366:in `klass'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:129:in `map'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:129:in `dependent_models'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:101:in `deletable?'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:61:in `block (3 levels) in detect'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:61:in `each'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:61:in `partition'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:61:in `block (2 levels) in detect'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:51:in `each'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:51:in `block in detect'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:44:in `each'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/incorrect_dependent_option.rb:44:in `detect'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/base.rb:50:in `run'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/detectors/base.rb:17:in `run'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/runner.rb:15:in `block in run_one'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/errors.rb:5:in `handle_exception'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/runner.rb:14:in `run_one'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/runner.rb:26:in `block in run_all'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/runner.rb:25:in `each'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/runner.rb:25:in `run_all'
/usr/local/bundle/bundler/gems/active_record_doctor-cbb9183887f1/lib/active_record_doctor/rake/task.rb:60:in `block in define'
/usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<main>'
Tasks: TOP => active_record_doctor
(See full trace by running task with --trace)
Thoughts?
Looks like a bug in the app itself. Notice that Map
defines screen_section_locations
(with emphasis on screen
) and the other class is named StorySectionLocation
(with emphasis on Story
).
@gregnavis LOL, you're right. All works now. 🥇
I have a Polymorphic
belongs_to
like this:I get this error when running the rake task:
I guess a) it shouldn't error out and b) should give some advice on what to do.