diff --git a/app/components/avo/fields/belongs_to_field/autocomplete_component.rb b/app/components/avo/fields/belongs_to_field/autocomplete_component.rb index ffcdacc301..87b2894af0 100644 --- a/app/components/avo/fields/belongs_to_field/autocomplete_component.rb +++ b/app/components/avo/fields/belongs_to_field/autocomplete_component.rb @@ -41,7 +41,7 @@ def field_value end def reflection_class - has_polymorphic_association? ? polymorphic_class : @resource.model_class._reflections[@field.id.to_s].klass + has_polymorphic_association? ? polymorphic_class : @resource.model_class.reflect_on_association(@field.id).klass end private diff --git a/app/components/avo/fields/has_one_field/show_component.rb b/app/components/avo/fields/has_one_field/show_component.rb index a20953faa5..f6e80a31c5 100644 --- a/app/components/avo/fields/has_one_field/show_component.rb +++ b/app/components/avo/fields/has_one_field/show_component.rb @@ -36,7 +36,7 @@ def can_see_the_create_button? end def create_path - association_id = @field.resource.model_class._reflections[@field.id.to_s].inverse_of.name + association_id = @field.resource.model_class.reflect_on_association(@field.id).inverse_of.name args = { via_relation: association_id, diff --git a/app/controllers/avo/application_controller.rb b/app/controllers/avo/application_controller.rb index 7d7431134f..521159eaa6 100644 --- a/app/controllers/avo/application_controller.rb +++ b/app/controllers/avo/application_controller.rb @@ -226,7 +226,7 @@ def related_resource return field.use_resource if field&.use_resource.present? - reflection = @model._reflections[params[:related_name]] + reflection = @model.class.reflect_on_association(params[:related_name]) reflected_model = reflection.klass diff --git a/app/controllers/avo/associations_controller.rb b/app/controllers/avo/associations_controller.rb index 698b9a2597..c44bf64bd4 100644 --- a/app/controllers/avo/associations_controller.rb +++ b/app/controllers/avo/associations_controller.rb @@ -101,7 +101,7 @@ def order private def set_reflection - @reflection = @model._reflections[params[:related_name].to_s] + @reflection = @model.class.reflect_on_association(params[:related_name]) end def set_attachment_class @@ -127,7 +127,7 @@ def attachment_id end def reflection_class - reflection = @model._reflections[params[:related_name]] + reflection = @model.class.reflect_on_association(params[:related_name]) klass = reflection.class.name.demodulize.to_s klass = reflection.through_reflection.class.name.demodulize.to_s if klass == "ThroughReflection" diff --git a/app/controllers/avo/base_controller.rb b/app/controllers/avo/base_controller.rb index 4e26e87171..6cd972ba4b 100644 --- a/app/controllers/avo/base_controller.rb +++ b/app/controllers/avo/base_controller.rb @@ -134,7 +134,7 @@ def create # This means that the record has been created through another parent record and we need to attach it somehow. if params[:via_resource_id].present? && params[:via_belongs_to_resource_class].nil? - @reflection = @model._reflections[params[:via_relation]] + @reflection = @model.class.reflect_on_association(params[:via_relation]) # Figure out what kind of association does the record have with the parent record # Fills in the required infor for belongs_to and has_many