lib/avo/base_resource.rb in avo-1.18.1 vs lib/avo/base_resource.rb in avo-1.18.2.pre.0
- old
+ new
@@ -72,11 +72,11 @@
Avo::Services::AuthorizationService.new Avo::App.current_user
end
end
def initialize
- self.class.model_class = model_class
+ self.class.model_class = model_class.base_class
end
def hydrate(model: nil, view: nil, user: nil, params: nil)
@view = view if view.present?
@user = user if user.present?
@@ -196,14 +196,17 @@
def class_name_without_resource
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 @model.class if @model.present?
+ # get the model class off of the model
+ return @model.base_class if @model.present?
+ # generate a model class
class_name_without_resource.safe_constantize
end
def model_title
return @model.send title if @model.present?
@@ -407,8 +410,12 @@
def description
description_field.value
rescue
nil
+ end
+
+ def form_scope
+ model.class.base_class.to_s.downcase
end
end
end