From 25f1cbdecd4f506b46a6c476f18074dafdb581f2 Mon Sep 17 00:00:00 2001 From: Christophe Maximin Date: Wed, 7 Nov 2018 22:38:41 +0000 Subject: Guard Enums against definitions with blank label names --- activerecord/lib/active_record/enum.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index 3d97e4e513..3a600835e1 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -218,6 +218,10 @@ module ActiveRecord MSG raise ArgumentError, error_message end + + if values.is_a?(Hash) && values.keys.any?(&:blank?) || values.is_a?(Array) && values.any?(&:blank?) + raise ArgumentError, "Enum label name must not be blank." + end end ENUM_CONFLICT_MESSAGE = \ -- cgit v1.2.3