lib/avo/base_resource.rb in avo-1.25.2 vs lib/avo/base_resource.rb in avo-2.0.0
- old
+ new
@@ -90,11 +90,13 @@
end
end
def initialize
unless self.class.model_class.present?
- self.class.model_class = model_class.base_class
+ if model_class.present?
+ self.class.model_class = model_class.base_class
+ end
end
end
def hydrate(model: nil, view: nil, user: nil, params: nil)
@view = view if view.present?
@@ -207,13 +209,13 @@
def default_panel_name
return @params[:related_name].capitalize if @params.present? && @params[:related_name].present?
case @view
when :show
- I18n.t("avo.resource_details", item: name.downcase, title: model_title).upcase_first
+ model_title
when :edit
- I18n.t("avo.update_item", item: name.downcase, title: model_title).upcase_first
+ model_title
when :new
I18n.t("avo.create_new_item", item: name.downcase).upcase_first
end
end
@@ -404,16 +406,12 @@
end
# This is used as the model class ID
# We use this instead of the route_key to maintain compatibility with uncountable models
# With uncountable models route key appends an _index suffix (Fish->fish_index)
- # Example: User->users, MediaItem->media_items, Fish->fish
+ # Example: User->users, MediaItem->medie_items, Fish->fish
def model_key
model_class.model_name.plural
- end
-
- def model_name
- model_class.model_name
end
def singular_model_key
model_class.model_name.singular
end