diff options
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/CHANGELOG.md | 21 | ||||
-rw-r--r-- | activemodel/README.rdoc | 14 | ||||
-rw-r--r-- | activemodel/test/cases/serializers/xml_serialization_test.rb | 4 |
3 files changed, 19 insertions, 20 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']} diff --git a/activemodel/test/cases/serializers/xml_serialization_test.rb b/activemodel/test/cases/serializers/xml_serialization_test.rb index 99a9c1fe33..04ecf8a31b 100644 --- a/activemodel/test/cases/serializers/xml_serialization_test.rb +++ b/activemodel/test/cases/serializers/xml_serialization_test.rb @@ -50,14 +50,10 @@ class XmlSerializationTest < ActiveModel::TestCase customer.name = "John" @contact.preferences = customer @contact.address = Address.new - @contact.address.street = "123 Lane" @contact.address.city = "Springfield" - @contact.address.state = "CA" - @contact.address.zip = 11111 @contact.address.apt_number = 35 @contact.friends = [Contact.new, Contact.new] @related_contact = SerializableContact.new - @related_contact.name = "related" @contact.contact = @related_contact end |