aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/examples
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-07-21 11:27:23 -0300
committerEmilio Tagua <miloops@gmail.com>2009-07-21 11:27:23 -0300
commitf32c3709830eb8d9f68a59c94f6791621c2b52ac (patch)
treeb34cf0b9321dfd40b795cc761b158be4cbde48f6 /activemodel/examples
parent9a28bd787660b08aae36155066e61d3608d0b4dd (diff)
parent9d7aae710384fb5f04129c35b86c5ea5fb9d83a9 (diff)
downloadrails-f32c3709830eb8d9f68a59c94f6791621c2b52ac.tar.gz
rails-f32c3709830eb8d9f68a59c94f6791621c2b52ac.tar.bz2
rails-f32c3709830eb8d9f68a59c94f6791621c2b52ac.zip
Merge commit 'rails/master'
Diffstat (limited to 'activemodel/examples')
-rw-r--r--activemodel/examples/validations.rb (renamed from activemodel/examples/amo_ap_example.rb)23
1 files changed, 8 insertions, 15 deletions
diff --git a/activemodel/examples/amo_ap_example.rb b/activemodel/examples/validations.rb
index cef718d0d4..3f8311ff96 100644
--- a/activemodel/examples/amo_ap_example.rb
+++ b/activemodel/examples/validations.rb
@@ -1,31 +1,24 @@
-$:.push "activesupport/lib"
-$:.push "activemodel/lib"
-
-require "active_model/validations"
-require "active_model/deprecated_error_methods"
-require "active_model/errors"
-require "active_model/naming"
+require 'activemodel'
class Person
+ include ActiveModel::Conversion
include ActiveModel::Validations
- extend ActiveModel::Naming
-
+
validates_presence_of :name
-
+
attr_accessor :name
+
def initialize(attributes = {})
@name = attributes[:name]
end
-
+
def persist
@persisted = true
end
-
+
def new_record?
@persisted
end
-
- def to_model() self end
end
person1 = Person.new
@@ -33,4 +26,4 @@ p person1.valid?
person1.errors
person2 = Person.new(:name => "matz")
-p person2.valid? \ No newline at end of file
+p person2.valid?