mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Updated documentation for serialize
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@512 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
10220d356d
commit
66f44e6cbb
2 changed files with 5 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue