lib/avo/base_resource.rb in avo-2.29.0 vs lib/avo/base_resource.rb in avo-2.29.1.pre.pr1652
- old
+ new
@@ -380,10 +380,11 @@
reflection = @model._reflections[@params[:via_relation]]
if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params[:via_relation_class])
# set the value to the actual record
- value = @params[:via_relation_class].safe_constantize.find(@params[:via_resource_id])
+ via_resource = ::Avo::App.get_resource_by_model_name(@params[:via_relation_class])
+ value = via_resource.find_record(@params[:via_resource_id])
elsif reflection.present? && reflection.foreign_key.present? && field.id.to_s == @params[:via_relation].to_s
resource = Avo::App.get_resource_by_model_name params[:via_relation_class]
model = resource.find_record @params[:via_resource_id], params: params
id_param = reflection.options[:primary_key] || :id