From 27572cbe680b8bdaa6253d932f41cc91290bc16a Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 16 Dec 2019 16:18:28 +0000 Subject: [PATCH] Remove alias_method klass_for_with_sym_fallback --- app/helpers/spree/admin/navigation_helper.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/helpers/spree/admin/navigation_helper.rb b/app/helpers/spree/admin/navigation_helper.rb index 4a84b94f11..19c746aa99 100644 --- a/app/helpers/spree/admin/navigation_helper.rb +++ b/app/helpers/spree/admin/navigation_helper.rb @@ -52,22 +52,20 @@ module Spree # :products returns Spree::Product # :my_products returns MyProduct if MyProduct is defined # :my_products returns My::Product if My::Product is defined - # if cannot constantize it returns nil - # This will allow us to use cancan abilities on tab + # + # If it cannot constantize, it tries a collection of custom translations + # + # This allows us to use cancan abilities on tab def klass_for(name) model_name = name.to_s - - ["Spree::#{model_name.classify}", model_name.classify, model_name.tr('_', '/').classify]. + klass = ["Spree::#{model_name.classify}", + model_name.classify, + model_name.tr('_', '/').classify]. find(&:safe_constantize). try(:safe_constantize) - end - # Make it so that the Reports admin tab can be enabled/disabled through the cancan - # :report resource, since it does not have a corresponding resource class (unlike - # eg. Spree::Product). - def klass_for_with_sym_fallback(name) - klass = klass_for_without_sym_fallback(name) klass ||= name.singularize.to_sym + klass = :overview if klass == :dashboard klass = Spree::Order if klass == :bulk_order_management klass = EnterpriseGroup if klass == :group @@ -76,7 +74,6 @@ module Spree klass = Spree::Admin::ReportsController if klass == :report klass end - alias_method_chain :klass_for, :sym_fallback def link_to_clone(resource, options = {}) options[:data] = { action: 'clone' }