lib/avo/base_resource.rb in avo-2.10.2 vs lib/avo/base_resource.rb in avo-2.10.3.pre.1

- old
+ new

@@ -8,10 +8,12 @@ include Avo::Concerns::HasFields include Avo::Concerns::HasStimulusControllers include Avo::Concerns::ModelClassConstantized delegate :view_context, to: ::Avo::App + delegate :current_user, to: ::Avo::App + delegate :params, to: ::Avo::App delegate :simple_format, :content_tag, to: :view_context delegate :main_app, to: :view_context delegate :avo, to: :view_context delegate :resource_path, to: :view_context delegate :resources_path, to: :view_context @@ -99,11 +101,11 @@ end end def initialize unless self.class.model_class.present? - if model_class.present? + if model_class.present? && model_class.respond_to?(:base_class) self.class.model_class = model_class.base_class end end end @@ -151,11 +153,11 @@ t("avo.create_new_item", item: name.downcase).upcase_first end end def class_name_without_resource - self.class.name.demodulize.chomp("Resource") + self.class.name.demodulize.delete_suffix("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? @@ -197,10 +199,10 @@ self.class.translation_key end def name - default = class_name_without_resource.titlecase + default = class_name_without_resource.to_s.gsub('::', ' ').underscore.humanize return @name if @name.present? if translation_key && ::Avo::App.translation_enabled t(translation_key, count: 1, default: default).capitalize