aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2015-02-13 23:51:43 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2015-02-13 23:51:43 -0800
commite076d7290d523759900ee1ba3c9843c7f324adc7 (patch)
tree98997cf8cdd7d26d8b5b6f8ca511bc3bd24ba167 /activerecord/lib/active_record
parent53f3803b52bfe2f4a8e0550a0c5d9df1865d90cb (diff)
downloadrails-e076d7290d523759900ee1ba3c9843c7f324adc7.tar.gz
rails-e076d7290d523759900ee1ba3c9843c7f324adc7.tar.bz2
rails-e076d7290d523759900ee1ba3c9843c7f324adc7.zip
Fixed a bug where NULLs are casted into the first enum value
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/enum.rb1
1 files changed, 1 insertions, 0 deletions
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