aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/CHANGELOG.md21
-rw-r--r--activemodel/README.rdoc14
2 files changed, 19 insertions, 16 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index 9aee47bd52..a1f3d081db 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -3,6 +3,8 @@
* Add `ActiveModel::Errors#full_messages_for`, to return all the error messages
for a given attribute.
+ Example:
+
class Person
include ActiveModel::Validations
@@ -19,26 +21,27 @@
* Added a method so that validations can be easily cleared on a model.
For example:
- class Person
- include ActiveModel::Validations
+ class Person
+ include ActiveModel::Validations
- validates_uniqueness_of :first_name
- validate :cannot_be_robot
+ validates_uniqueness_of :first_name
+ validate :cannot_be_robot
- def cannot_be_robot
- errors.add(:base, 'A person cannot be a robot') if person_is_robot
+ def cannot_be_robot
+ errors.add(:base, 'A person cannot be a robot') if person_is_robot
+ end
end
- end
Now, if someone runs `Person.clear_validators!`, then the following occurs:
- Person.validators # => []
- Person._validate_callbacks.empty? # => true
+ Person.validators # => []
+ Person._validate_callbacks.empty? # => true
*John Wang*
* `has_secure_password` does not fail the confirmation validation
when assigning empty String to `password` and `password_confirmation`.
+ Fixes #9535.
Example:
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index a66225319d..a399fe9051 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -24,8 +24,8 @@ to integrate with Action Pack out of the box: <tt>ActiveModel::Model</tt>.
end
person = Person.new(name: 'bob', age: '18')
- person.name # => 'bob'
- person.age # => '18'
+ person.name # => 'bob'
+ person.age # => '18'
person.valid? # => true
It includes model name introspections, conversions, translations and
@@ -82,12 +82,12 @@ behavior out of the box:
end
person = Person.new
- person.name # => nil
- person.changed? # => false
+ person.name # => nil
+ person.changed? # => false
person.name = 'bob'
- person.changed? # => true
- person.changed # => ['name']
- person.changes # => { 'name' => [nil, 'bob'] }
+ person.changed? # => true
+ person.changed # => ['name']
+ person.changes # => { 'name' => [nil, 'bob'] }
person.name = 'robert'
person.save
person.previous_changes # => {'name' => ['bob, 'robert']}