Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7107

Show
Ignore:
Timestamp:
06/23/07 17:52:50 (3 years ago)
Author:
david
Message:

Docfix (closes #8096)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/base.rb

    r7101 r7107  
    641641 
    642642 
    643       # Specifies that the attribute by the name of +attr_name+ should be serialized before saving to the database and unserialized 
    644       # after loading from the database. The serialization is done through YAML. If +class_name+ is specified, the serialized 
    645       # object must be of that class on retrieval, or nil. Otherwise, +SerializationTypeMismatch+ will be raised. 
     643      # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object,  
     644      # then specify the name of that attribute using this method and it will be handled automatically.   
     645      # The serialization is done through YAML. If +class_name+ is specified, the serialized object must be of that  
     646      # class on retrieval or +SerializationTypeMismatch+ will be raised. 
     647      # 
     648      # ==== Options 
     649      # 
     650      # +attr_name+   The field name that should be serialized 
     651      # +class_name+  Optional, class name that the object should be equal to 
     652      # 
     653      # ==== Example 
     654      #   # Serialize a preferences attribute 
     655      #   class User 
     656      #     serialize :preferences 
     657      #   end 
    646658      def serialize(attr_name, class_name = Object) 
    647659        serialized_attributes[attr_name.to_s] = class_name