lib/express_admin/commandable.rb in express_admin-1.8.1 vs lib/express_admin/commandable.rb in express_admin-2.0.0.a

- old
+ new

@@ -15,23 +15,24 @@ # controllers to exist for the route map to be constructed controller_name = mapper.send(:parent_resource).controller scope = mapper.instance_variable_get(:@scope) while scope.respond_to?(:parent) && scope = scope.parent - possible_module = scope.instance_variable_get(:@hash)[:module] - break if possible_module.nil? + possible_module = scope.instance_variable_get(:@hash).try(:[],:module) modules << possible_module end - modules.compact! + modules.uniq!.compact! modules << controller_name controller_class = nil begin - controller_class = "#{modules.join("/").classify.pluralize}Controller".constantize + controller_class_name = "#{modules.join("/").classify.pluralize}Controller" + controller_class = controller_class_name.constantize rescue NameError => e # if plural fails, use singular begin - controller_class = "#{modules.join("/").classify}Controller".constantize + controller_class_name = "#{modules.join("/").classify}Controller" + controller_class = controller_class_name.constantize rescue NameError => e2 # if we get here, the first exception wasn't what we thought # it was something else and we should politely let the developer know raise e end