diff --git a/lib/coach/handler.rb b/lib/coach/handler.rb
index <HASH>..<HASH> 100644
--- a/lib/coach/handler.rb
+++ b/lib/coach/handler.rb
@@ -93,7 +93,11 @@ module Coach
     end
 
     def middleware
-      @middleware ||= ActiveSupport::Dependencies.constantize(name)
+      @middleware ||= if ActiveSupport::Dependencies.respond_to?(:constantize)
+                        ActiveSupport::Dependencies.constantize(name)
+                      else
+                        name.constantize
+                      end
     end
 
     # Remove middleware that have been included multiple times with the same
Remove reference to ActiveSupport::Dependencies

This is removed in rails 7 due to the classic autoloader being removed -
see <URL>