From df167a952840e7cb7a7a5dffa9dced097a000438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Tue, 30 Jul 2024 20:42:45 +0200 Subject: [PATCH] Move to reflect_on_association. --- lib/avo/fields/belongs_to_field.rb | 8 ++++---- lib/avo/fields/has_base_field.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/avo/fields/belongs_to_field.rb b/lib/avo/fields/belongs_to_field.rb index 76bfe47e4e..a93c442a2d 100644 --- a/lib/avo/fields/belongs_to_field.rb +++ b/lib/avo/fields/belongs_to_field.rb @@ -245,10 +245,10 @@ def target_resource reflection_key = polymorphic_as || id - if @model.class.reflections[reflection_key.to_s].klass.present? - App.get_resource_by_model_name @model.class.reflections[reflection_key.to_s].klass.to_s - elsif @model.class.reflections[reflection_key.to_s].options[:class_name].present? - App.get_resource_by_model_name @model.class.reflections[reflection_key.to_s].options[:class_name] + if @model.class.reflect_on_association(reflection_key).klass.present? + App.get_resource_by_model_name @model.class.reflect_on_association(reflection_key).klass.to_s + elsif @model.class.reflect_on_association(reflection_key).options[:class_name].present? + App.get_resource_by_model_name @model.class.reflect_on_association(reflection_key).options[:class_name] else App.get_resource_by_name reflection_key.to_s end diff --git a/lib/avo/fields/has_base_field.rb b/lib/avo/fields/has_base_field.rb index 4a63446ebd..d161b402e2 100644 --- a/lib/avo/fields/has_base_field.rb +++ b/lib/avo/fields/has_base_field.rb @@ -59,10 +59,10 @@ def field_label end def target_resource - if @model.class.reflections[id.to_s].klass.present? - Avo::App.get_resource_by_model_name @model.class.reflections[id.to_s].klass.to_s - elsif @model.class.reflections[id.to_s].options[:class_name].present? - Avo::App.get_resource_by_model_name @model.class.reflections[id.to_s].options[:class_name] + if @model.class.reflect_on_association(id).klass.present? + Avo::App.get_resource_by_model_name @model.class.reflect_on_association(id).klass.to_s + elsif @model.class.reflect_on_association(id).options[:class_name].present? + Avo::App.get_resource_by_model_name @model.class.reflect_on_association(id).options[:class_name] else Avo::App.get_resource_by_name id.to_s end