diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-05-28 15:51:53 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-05-28 15:51:53 +0000 |
commit | 4472a30aadc35f8a9a67db8b0a2a7318c3a0dcfd (patch) | |
tree | 9a7582184fb23eb8e553e26ec97cf62a9b5ae564 /activerecord/lib/active_record | |
parent | 6f6328787cb0ba61f7af1e733826b5ffcdd6a398 (diff) | |
download | rails-4472a30aadc35f8a9a67db8b0a2a7318c3a0dcfd.tar.gz rails-4472a30aadc35f8a9a67db8b0a2a7318c3a0dcfd.tar.bz2 rails-4472a30aadc35f8a9a67db8b0a2a7318c3a0dcfd.zip |
Allow nil serialized attributes with a set class constraint. #7293 [sandofsky]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6879 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 3ba1cb26d1..36775d74b5 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -643,7 +643,7 @@ module ActiveRecord #:nodoc: # Specifies that the attribute by the name of +attr_name+ should be serialized before saving to the database and unserialized # after loading from the database. The serialization is done through YAML. If +class_name+ is specified, the serialized - # object must be of that class on retrieval or +SerializationTypeMismatch+ will be raised. + # object must be of that class on retrieval, or nil. Otherwise, +SerializationTypeMismatch+ will be raised. def serialize(attr_name, class_name = Object) serialized_attributes[attr_name.to_s] = class_name end @@ -2110,7 +2110,7 @@ module ActiveRecord #:nodoc: def unserialize_attribute(attr_name) unserialized_object = object_from_yaml(@attributes[attr_name]) - if unserialized_object.is_a?(self.class.serialized_attributes[attr_name]) + if unserialized_object.is_a?(self.class.serialized_attributes[attr_name]) || unserialized_object.nil? @attributes[attr_name] = unserialized_object else raise SerializationTypeMismatch, |