Permalink
Browse files

Docfix (closes #8096)

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7107 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Jun 23, 2007
1 parent b00e6a9 commit 1a0cdf74be951f9e732cfb8e6e1cd8a087c8ebdf
Showing with 15 additions and 3 deletions.
  1. +15 −3 activerecord/lib/active_record/base.rb
@@ -640,9 +640,21 @@ def accessible_attributes # :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

0 comments on commit 1a0cdf7

Please sign in to comment.