aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 20:00:20 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 20:00:20 +0000
commit66f44e6cbbec39e217f9cff167608f98ecc6260a (patch)
tree28fe3421a72aca730e6e532c11a97e21e3584810
parent10220d356dccb6ccdfe3d1a91531511d6f0a9cf8 (diff)
downloadrails-66f44e6cbbec39e217f9cff167608f98ecc6260a.tar.gz
rails-66f44e6cbbec39e217f9cff167608f98ecc6260a.tar.bz2
rails-66f44e6cbbec39e217f9cff167608f98ecc6260a.zip
Updated documentation for serialize
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@512 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-xactiverecord/lib/active_record/base.rb7
-rwxr-xr-xactiverecord/test/base_test.rb2
2 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index b0ad90b10b..293fe0c833 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -124,11 +124,11 @@ module ActiveRecord #:nodoc:
# user = User.create("preferences" => { "background" => "black", "display" => large })
# User.find(user.id).preferences # => { "background" => "black", "display" => large }
#
- # You can also specify an optional :class_name option that'll raise an exception if a serialized object is retrieved as a
+ # You can also specify an class option as the second parameter that'll raise an exception if a serialized object is retrieved as a
# descendent of a class not in the hierarchy. Example:
#
# class User < ActiveRecord::Base
- # serialize :preferences, :class_name => "Hash"
+ # serialize :preferences, Hash
# end
#
# user = User.create("preferences" => %w( one two three ))
@@ -171,8 +171,7 @@ module ActiveRecord #:nodoc:
# * +AdapterNotSpecified+ -- the <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified an unexisting adapter
# (or a bad spelling of an existing one).
# * +AssociationTypeMismatch+ -- the object assigned to the association wasn't of the type specified in the association definition.
- # * +SerializationTypeMismatch+ -- the object serialized wasn't of the class specified in the <tt>:class_name</tt> option of
- # the serialize definition.
+ # * +SerializationTypeMismatch+ -- the object serialized wasn't of the class specified as the second parameter.
# * +ConnectionNotEstablished+ -- no connection has been established. Use <tt>establish_connection</tt> before querying.
# * +RecordNotFound+ -- no record responded to the find* method.
# Either the row with the given ID doesn't exist or the row didn't meet the additional restrictions.
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index 0f93f2ffbc..3d6367fe73 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -609,6 +609,8 @@ class BasicsTest < Test::Unit::TestCase
topic = Topic.create("content" => myobj)
Topic.serialize("content", MyObject)
assert_equal(myobj, topic.content)
+
+ assert_equal(myobj, topic.content)
end
def test_serialized_attribute_with_class_constraint