From 1a0cdf74be951f9e732cfb8e6e1cd8a087c8ebdf Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 23 Jun 2007 17:52:50 +0000 Subject: Docfix (closes #8096) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7107 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/base.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 527c2fef5a..9d2e186672 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -640,9 +640,21 @@ module ActiveRecord #:nodoc: end - # 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 nil. Otherwise, +SerializationTypeMismatch+ will be raised. + # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object, + # then specify the name of that attribute using this method and it will be handled automatically. + # 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. + # + # ==== Options + # + # +attr_name+ The field name that should be serialized + # +class_name+ Optional, class name that the object should be equal to + # + # ==== Example + # # Serialize a preferences attribute + # class User + # serialize :preferences + # end def serialize(attr_name, class_name = Object) serialized_attributes[attr_name.to_s] = class_name end -- cgit v1.2.3