lib/avo/base_resource.rb in avo-2.25.1.pre.1.pr1579 vs lib/avo/base_resource.rb in avo-2.26.0
- old
+ new
@@ -40,13 +40,10 @@
class_attribute :grid_loader
class_attribute :visible_on_sidebar, default: true
class_attribute :unscoped_queries_on_index, default: false
class_attribute :resolve_query_scope
class_attribute :resolve_find_scope
- class_attribute :find_record_method, default: ->(model_class:, id:) {
- model_class.find id
- }
class_attribute :ordering
class_attribute :hide_from_global_search, default: false
class_attribute :after_create_path, default: :show
class_attribute :after_update_path, default: :show
class_attribute :record_selector, default: true
@@ -380,15 +377,11 @@
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])
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]
- id_param = reflection.options[:primary_key] || :id
-
- value = model.send(id_param)
+ value = @params[:via_resource_id]
end
end
[id, value]
end
@@ -492,14 +485,8 @@
Avo::Hosts::Ordering.new resource: self, options: self.class.ordering, **args
end
def has_model_id?
model.present? && model.id.present?
- end
-
- def find_record(id, query: nil)
- query ||= self.class.find_scope
-
- self.class.find_record_method.call(model_class: query, id: id)
end
end
end