From e076d7290d523759900ee1ba3c9843c7f324adc7 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Fri, 13 Feb 2015 23:51:43 -0800 Subject: Fixed a bug where NULLs are casted into the first enum value --- activerecord/lib/active_record/enum.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index 442fb3fdc9..1afbfb1977 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -106,6 +106,7 @@ module ActiveRecord end def type_cast_from_database(value) + return if value.nil? mapping.key(value.to_i) end -- cgit v1.2.3