CHANGELOG.md 2.3 KB
Newer Older
1 2 3 4
*   `#to_param` returns `nil` if `#to_key` returns `nil`. Fixes #11399.

    *Yves Senn*

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
*   Ability to specify multiple contexts when defining a validation.

    Example:

        class Person
          include ActiveModel::Validations

          attr_reader :name
          validates_presence_of :name, on: [:verify, :approve]
        end

        person = Person.new
        person.valid?                           # => true
        person.valid?(:verify)                  # => false
        person.errors.full_messages_for(:name)  # => ["Name can't be blank"]
        person.valid?(:approve)                 # => false
        person.errors.full_messages_for(:name)  # => ["Name can't be blank"]

    *Vince Puzzella*

Y
Yves Senn 已提交
25 26
*   `attribute_changed?` now accepts a hash to check if the attribute was
    changed `:from` and/or `:to` a given value.
27

Y
Yves Senn 已提交
28 29 30
    Example:

        model.name_changed?(from: "Pete", to: "Ringo")
31 32 33

    *Tejas Dinkar*

34 35 36 37
*   Fix `has_secure_password` to honor bcrypt-ruby's cost attribute.

    *T.J. Schuck*

38
*   Updated the `ActiveModel::Dirty#changed_attributes` method to be indifferent between using
39 40 41 42
    symbols and strings as keys.

    *William Myers*

43
*   Added new API methods `reset_changes` and `changes_applied` to `ActiveModel::Dirty`
44 45 46 47 48
    that control changes state. Previsously you needed to update internal
    instance variables, but now API methods are available.

    *Bogdan Gusiev*

49 50
*   Fix `has_secure_password` not to trigger `password_confirmation` validations
    if no `password_confirmation` is set.
51 52 53

    *Vladimir Kiselev*

54 55 56 57 58
*   `inclusion` / `exclusion` validations with ranges will only use the faster
    `Range#cover` for numerical ranges, and the more accurate `Range#include?`
    for non-numerical ones.

    Fixes range validations like `:a..:f` that used to pass with values like `:be`.
59
    Fixes #10593.
60 61 62

    *Charles Bergeron*

63
*   Fix regression in `has_secure_password`. When a password is set, but a
64 65 66 67
    confirmation is an empty string, it would incorrectly save.

    *Steve Klabnik* and *Phillip Calvin*

68 69 70
*   Deprecate `Validator#setup`. This should be done manually now in the validator's constructor.

    *Nick Sutterer*
R
Rafael Mendonça França 已提交
71

72
Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activemodel/CHANGELOG.md) for previous changes.