allow reloading of models

This commit is contained in:
Dylan Knutson
2025-07-18 16:40:18 +00:00
parent 5cf9cfbc81
commit 26ad0e3ea3
2 changed files with 23 additions and 0 deletions

View File

@@ -83,6 +83,11 @@ module HasAuxTable
aux_class_name = aux_table_name.to_s.camelize
aux_association_name = aux_table_name.to_s.singularize.to_sym
# Ensure the class name doesn't conflict with existing constants
if Object.const_defined?(aux_class_name)
Object.send(:remove_const, aux_class_name)
end
# Get the current class for the association
main_class = T.cast(self, T.class_of(ActiveRecord::Base))
main_association_name = foreign_key.to_s.delete_suffix("_id").to_sym