Skip to content

Commit

Permalink
Move to reflect_on_association.
Browse files Browse the repository at this point in the history
  • Loading branch information
simi committed Jul 30, 2024
1 parent 9204df7 commit df167a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/avo/fields/belongs_to_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/avo/fields/has_base_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df167a9

Please sign in to comment.