lib/avo/base_resource.rb in avo-2.9.0 vs lib/avo/base_resource.rb in avo-2.9.1.pre1

- old
+ new

@@ -76,18 +76,18 @@ query_scope end # This resolves the scope when doing "where" queries (not find queries) def query_scope - final_scope = resolve_query_scope.present? ? resolve_query_scope.call(model_class: model_class) : model_class + final_scope = resolve_query_scope.present? ? resolve_query_scope.call(model_class: get_model_class) : get_model_class authorization.apply_policy final_scope end # This resolves the scope when finding records (not "where" queries) def find_scope - final_scope = resolve_find_scope.present? ? resolve_find_scope.call(model_class: model_class) : model_class + final_scope = resolve_find_scope.present? ? resolve_find_scope.call(model_class: get_model_class) : get_model_class authorization.apply_policy final_scope end def authorization @@ -97,10 +97,18 @@ def order_actions return {} if ordering.blank? ordering.dig(:actions) || {} end + + def get_model_class + if model_class.is_a? String + model_class.safe_constantize + else + model_class + end + end end def initialize unless self.class.model_class.present? if model_class.present? @@ -250,10 +258,10 @@ self.class.name.demodulize.chomp("Resource") end def model_class # get the model class off of the static property - return self.class.model_class if self.class.model_class.present? + return self.class.get_model_class if self.class.get_model_class.present? # get the model class off of the model return @model.base_class if @model.present? # generate a model class