lib/avo/base_resource.rb in avo-3.0.0.pre9 vs lib/avo/base_resource.rb in avo-3.0.0.pre10
- old
+ new
@@ -50,12 +50,13 @@
class_attribute :actions_loader
class_attribute :scopes_loader
class_attribute :filters_loader
class_attribute :grid_loader
class_attribute :visible_on_sidebar, default: true
- class_attribute :unscoped_queries_on_index, default: false
- class_attribute :index_query
+ class_attribute :index_query, default: -> {
+ query
+ }
class_attribute :find_record_method, default: -> {
query.find id
}
class_attribute :hide_from_global_search, default: false
class_attribute :after_create_path, default: :show
@@ -108,16 +109,13 @@
end
end
# This resolves the scope when doing "where" queries (not find queries)
def query_scope
- final_scope = if index_query.present?
- Avo::ExecutionContext.new(target: index_query, query: model_class).handle
- else
- model_class
- end
-
- authorization.apply_policy final_scope
+ authorization.apply_policy Avo::ExecutionContext.new(
+ target: index_query,
+ query: model_class
+ ).handle
end
# This resolves the scope when finding records (not "where" queries)
def find_scope
authorization.apply_policy model_class