Merge resource_controller model_class method with parent version

This commit is contained in:
Luis Ramos
2020-10-31 10:27:27 +00:00
committed by Andy Brett
parent abc58f5bb4
commit fc4cf6a9a7
2 changed files with 15 additions and 5 deletions

View File

@@ -1,9 +1,5 @@
module Admin
class ResourceController < Spree::Admin::ResourceController
def model_class
controller_name.classify.to_s.constantize
end
# URL helpers
def new_object_url(options = {})
if parent_data.present?

View File

@@ -124,7 +124,7 @@ module Spree
end
def model_class
"Spree::#{controller_name.classify}".constantize
controller_class_name.constantize
end
def model_name
@@ -277,6 +277,20 @@ module Spree
def new_actions
[:new, :create]
end
private
def controller_class_name
if spree_controller?
"Spree::#{controller_name.classify}"
else
controller_name.classify.to_s
end
end
def spree_controller?
controller_path.starts_with? "spree"
end
end
end
end