From 3555b6d75c6612ee1dd2c32245fe3cfa060aa3c3 Mon Sep 17 00:00:00 2001 From: Johan Halse Date: Wed, 18 Sep 2019 07:33:26 +0200 Subject: [PATCH] Fix `module_parents` deprecation warning (#249) --- lib/godmin/engine_wrapper.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/godmin/engine_wrapper.rb b/lib/godmin/engine_wrapper.rb index 6b398bcf..0278b030 100644 --- a/lib/godmin/engine_wrapper.rb +++ b/lib/godmin/engine_wrapper.rb @@ -40,8 +40,17 @@ def find_engine(controller) end end + # Some gymnastics because the `parents` function is slated for deprecation + # and being replaced by `module_parents` and we don't want to clutter our + # log with a million warnings + def parents_of(controller) + return controller.module_parents if controller.respond_to?(:module_parents) + + controller.parents + end + def find_engine_module(controller) - controller.parents.find do |parent| + parents_of(controller).find do |parent| parent.respond_to?(:use_relative_model_naming?) && parent.use_relative_model_naming? end end