lib/avo/base_resource.rb in avo-3.0.0.pre6 vs lib/avo/base_resource.rb in avo-3.0.0.pre7
- old
+ new
@@ -55,11 +55,11 @@
class_attribute :unscoped_queries_on_index, default: false
class_attribute :resolve_index_query
class_attribute :resolve_find_scope
# TODO: refactor this into a Host without args
class_attribute :find_record_method, default: -> {
- model_class.find id
+ query.find id
}
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
@@ -110,22 +110,22 @@
end
# This resolves the scope when doing "where" queries (not find queries)
def query_scope
final_scope = if resolve_index_query.present?
- Avo::ExecutionContext.new(target: resolve_index_query, model_class: model_class).handle
+ Avo::ExecutionContext.new(target: resolve_index_query, query: model_class).handle
else
model_class
end
authorization.apply_policy final_scope
end
# This resolves the scope when finding records (not "where" queries)
def find_scope
final_scope = if resolve_find_scope.present?
- Avo::ExecutionContext.new(target: resolve_find_scope, model_class: model_class).handle
+ Avo::ExecutionContext.new(target: resolve_find_scope, query: model_class).handle
else
model_class
end
authorization.apply_policy final_scope
@@ -534,14 +534,12 @@
def has_record_id?
record.present? && record_id.present?
end
def find_record(id, query: nil, params: nil)
- query ||= self.class.find_scope
-
Avo::ExecutionContext.new(
target: self.class.find_record_method,
- model_class: query,
+ query: query || self.class.find_scope,
id: id,
params: params
).handle
end