diff options
Diffstat (limited to 'activemodel/README.rdoc')
-rw-r--r-- | activemodel/README.rdoc | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index f6beff14e1..20414c1d61 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -49,7 +49,7 @@ behavior out of the box: send("#{attr}=", nil) end end - + person = Person.new person.clear_name person.clear_age @@ -132,7 +132,7 @@ behavior out of the box: "Name" end end - + person = Person.new person.name = nil person.validate! @@ -154,8 +154,8 @@ behavior out of the box: * Making objects serializable - ActiveModel::Serialization provides a standard interface for your object - to provide +to_json+ or +to_xml+ serialization. + <tt>ActiveModel::Serialization</tt> provides a standard interface for your object + to provide +to_json+ serialization. class SerialPerson include ActiveModel::Serialization @@ -177,13 +177,6 @@ behavior out of the box: s = SerialPerson.new s.to_json # => "{\"name\":null}" - class SerialPerson - include ActiveModel::Serializers::Xml - end - - s = SerialPerson.new - s.to_xml # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<serial-person... - {Learn more}[link:classes/ActiveModel/Serialization.html] * Internationalization (i18n) support @@ -216,10 +209,10 @@ behavior out of the box: {Learn more}[link:classes/ActiveModel/Validations.html] * Custom validators - + class HasNameValidator < ActiveModel::Validator def validate(record) - record.errors[:name] = "must exist" if record.name.blank? + record.errors.add(:name, "must exist") if record.name.blank? end end @@ -242,7 +235,7 @@ behavior out of the box: The latest version of Active Model can be installed with RubyGems: - % [sudo] gem install activemodel + % gem install activemodel Source code can be downloaded as part of the Rails project on GitHub |