aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/README.rdoc
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-03-03 04:19:39 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-03-03 04:45:30 -0300
commitcb9d03f0d46b17986894a3aadaad6eaa55dc66b3 (patch)
tree335ca7a33b6c58f82b441f48d077ce5e45998ece /activemodel/README.rdoc
parenteafa58b566c770d5d5dc5706464ab4b67e453464 (diff)
downloadrails-cb9d03f0d46b17986894a3aadaad6eaa55dc66b3.tar.gz
rails-cb9d03f0d46b17986894a3aadaad6eaa55dc66b3.tar.bz2
rails-cb9d03f0d46b17986894a3aadaad6eaa55dc66b3.zip
Add docs with usage examples for ActiveModel::Model
Also add test to ensure basic model does not explode when initialized with nil.
Diffstat (limited to 'activemodel/README.rdoc')
-rw-r--r--activemodel/README.rdoc19
1 files changed, 19 insertions, 0 deletions
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index a7ba27ba73..9b121510a9 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -13,6 +13,25 @@ in code duplication and fragile applications that broke on upgrades. Active
Model solves this by defining an explicit API. You can read more about the
API in ActiveModel::Lint::Tests.
+Active Model provides a default module that implements the basic API required
+to integrate with Action Pack out of the box: +ActiveModel::Model+.
+
+ class Person
+ include ActiveModel::Model
+
+ attr_accessor :name, :age
+ validates_presence_of :name
+ end
+
+ person = Person.new(:name => 'bob', :age => '18')
+ person.name # => 'bob'
+ person.age # => 18
+ person.valid? # => false
+
+It includes model name instrospection, conversions, translations and
+validations, resulting in a class suitable to be used with ActionPack.
+See +ActiveModel::Model+ for more examples.
+
Active Model also provides the following functionality to have ORM-like
behavior out of the box: