aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAditya Sanghi <asanghi@me.com>2010-11-29 18:13:17 +0530
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-08 15:51:47 -0800
commit7a237d56aa38c51987af0fd52d001989c4f3da07 (patch)
treed118c8bc7f9e1e4d25d2bb54d491d24899e610f3 /activerecord/lib
parent285f456391014c6e5ce1a694d43088012fbc7772 (diff)
downloadrails-7a237d56aa38c51987af0fd52d001989c4f3da07.tar.gz
rails-7a237d56aa38c51987af0fd52d001989c4f3da07.tar.bz2
rails-7a237d56aa38c51987af0fd52d001989c4f3da07.zip
Ensure that boolean false is properly serialized [#6079 state:resolved]
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb3
-rw-r--r--activerecord/lib/active_record/base.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index ad5a3e7562..506f6e878f 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -85,7 +85,8 @@ module ActiveRecord
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
- if value = @attributes[attr_name]
+ value = @attributes[attr_name]
+ unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index b55aaddbd7..7b9ce21ceb 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1680,7 +1680,7 @@ MSG
if include_readonly_attributes || (!include_readonly_attributes && !self.class.readonly_attributes.include?(name))
value = read_attribute(name)
- if value && self.class.serialized_attributes.key?(name)
+ if !value.nil? && self.class.serialized_attributes.key?(name)
value = YAML.dump value
end
attrs[self.class.arel_table[name]] = value