8000 Fix ActiveSupport::Dependencies.costantize · activeadmin/activeadmin@8bf3b1b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8bf3b1b

Browse files
committed
Fix ActiveSupport::Dependencies.costantize
This method has been removed in Rails 7 and replaced with `Constantine`
1 parent ba972e2 commit 8bf3b1b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/active_admin/base_controller/authorization.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ def active_admin_authorization
8282
def active_admin_authorization_adapter
8383
adapter = active_admin_namespace.authorization_adapter
8484
if adapter.is_a? String
85-
ActiveSupport::Dependencies.constantize adapter
85+
if ActiveSupport::Dependencies.respond_to?(:constantize)
86+
ActiveSupport::Dependencies.constantize(adapter)
87+
else
88+
adapter.constantize
89+
end
8690
else
8791
adapter
8892
end

lib/active_admin/resource.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ def initialize(namespace, resource_class, options = {})
9999
# The class this resource wraps. If you register the Post model, Resource#resource_class
100100
# will point to the Post class
101101
def resource_class
102-
ActiveSupport::Dependencies.constantize(resource_class_name)
102+
constantizer(resource_class_name)
103103
end
104104

105105
def decorator_class
106-
ActiveSupport::Dependencies.constantize(decorator_class_name) if decorator_class_name
106+
constantizer(decorator_class_name) if decorator_class_name
107107
end
108108

109109
def resource_name_extension
@@ -210,6 +210,14 @@ def default_csv_builder
210210
@default_csv_builder ||= CSVBuilder.default_for_resource(self)
211211
end
212212

213+
def constantizer(resource_name)
214+
if ActiveSupport::Dependencies.respond_to?(:constantize)
215+
ActiveSupport::Dependencies.constantize(resource_name)
216+
else
217+
resource_name.constantize
218+
end
219+
end
220+
213221
def define_resource_name_extension(resource)
214222
Module.new do
215223
define_method :model_name do

0 commit comments

Comments
 (0)
0