mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
improve serialization doc
This commit is contained in:
parent
93bcb0c268
commit
e34a4014ad
1 changed files with 5 additions and 4 deletions
|
@ -26,17 +26,18 @@ module ActiveModel
|
|||
# person.serializable_hash # => {"name"=>"Bob"}
|
||||
#
|
||||
# You need to declare an attributes hash which contains the attributes
|
||||
# you want to serialize. When called, serializable hash will use
|
||||
# you want to serialize. Attributes must be strings, not symbols.
|
||||
# When called, serializable hash will use
|
||||
# instance methods that match the name of the attributes hash's keys.
|
||||
# In order to override this behavior, take a look at the private
|
||||
# method read_attribute_for_serialization.
|
||||
# method ++read_attribute_for_serialization++.
|
||||
#
|
||||
# Most of the time though, you will want to include the JSON or XML
|
||||
# serializations. Both of these modules automatically include the
|
||||
# ActiveModel::Serialization module, so there is no need to explicitly
|
||||
# ++ActiveModel::Serialization++ module, so there is no need to explicitly
|
||||
# include it.
|
||||
#
|
||||
# So a minimal implementation including XML and JSON would be:
|
||||
# A minimal implementation including XML and JSON would be:
|
||||
#
|
||||
# class Person
|
||||
# include ActiveModel::Serializers::JSON
|
||||
|
|
Loading…
Reference in a new issue