diff options
author | Christophe Maximin <christophe.maximin@gmail.com> | 2018-11-07 22:38:41 +0000 |
---|---|---|
committer | Christophe Maximin <christophe.maximin@gmail.com> | 2018-11-07 23:36:39 +0000 |
commit | 25f1cbdecd4f506b46a6c476f18074dafdb581f2 (patch) | |
tree | 322a0212b12eb6de351076ecf40c635d036bf1de /activerecord/lib/active_record | |
parent | fc2684c9c012b95ce003cce22b378d5ea9ab56d3 (diff) | |
download | rails-25f1cbdecd4f506b46a6c476f18074dafdb581f2.tar.gz rails-25f1cbdecd4f506b46a6c476f18074dafdb581f2.tar.bz2 rails-25f1cbdecd4f506b46a6c476f18074dafdb581f2.zip |
Guard Enums against definitions with blank label names
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/enum.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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 = \ |