2020-05-02 02:33:43 -04:00
|
|
|
|
* Deprecate marshalling load from legacy attributes format.
|
|
|
|
|
|
|
|
|
|
*Ryuta Kamizono*
|
|
|
|
|
|
2020-01-27 16:01:22 -05:00
|
|
|
|
* `*_previously_changed?` accepts `:from` and `:to` keyword arguments like `*_changed?`.
|
|
|
|
|
|
|
|
|
|
topic.update!(status: :archived)
|
|
|
|
|
topic.status_previously_changed?(from: "active", to: "archived")
|
|
|
|
|
# => true
|
|
|
|
|
|
|
|
|
|
*George Claghorn*
|
|
|
|
|
|
2019-09-16 17:57:47 -04:00
|
|
|
|
* Raise FrozenError when trying to write attributes that aren't backed by the database on an object that is frozen:
|
|
|
|
|
|
|
|
|
|
class Animal
|
2019-11-23 19:20:00 -05:00
|
|
|
|
include ActiveModel::Attributes
|
|
|
|
|
attribute :age
|
2019-09-16 17:57:47 -04:00
|
|
|
|
end
|
2019-11-23 19:20:00 -05:00
|
|
|
|
|
2019-09-16 17:57:47 -04:00
|
|
|
|
animal = Animal.new
|
2019-11-23 19:20:00 -05:00
|
|
|
|
animal.freeze
|
2019-09-16 17:57:47 -04:00
|
|
|
|
animal.age = 25 # => FrozenError, "can't modify a frozen Animal"
|
2019-11-23 19:20:00 -05:00
|
|
|
|
|
|
|
|
|
*Josh Brody*
|
|
|
|
|
|
2020-02-25 00:14:54 -05:00
|
|
|
|
* Add `*_previously_was` attribute methods when dirty tracking. Example:
|
2019-03-29 05:21:56 -04:00
|
|
|
|
|
2019-08-01 18:38:03 -04:00
|
|
|
|
pirate.update(catchphrase: "Ahoy!")
|
|
|
|
|
pirate.previous_changes["catchphrase"] # => ["Thar She Blows!", "Ahoy!"]
|
|
|
|
|
pirate.catchphrase_previously_was # => "Thar She Blows!"
|
|
|
|
|
|
|
|
|
|
*DHH*
|
2019-03-29 05:21:56 -04:00
|
|
|
|
|
2019-04-28 08:25:51 -04:00
|
|
|
|
* Encapsulate each validation error as an Error object.
|
|
|
|
|
|
2020-04-15 08:23:24 -04:00
|
|
|
|
The `ActiveModel`’s `errors` collection is now an array of these Error
|
2019-04-28 08:25:51 -04:00
|
|
|
|
objects, instead of messages/details hash.
|
|
|
|
|
|
2020-04-15 08:23:24 -04:00
|
|
|
|
For each of these `Error` object, its `message` and `full_message` methods
|
|
|
|
|
are for generating error messages. Its `details` method would return error’s
|
2019-04-28 08:25:51 -04:00
|
|
|
|
extra parameters, found in the original `details` hash.
|
|
|
|
|
|
2020-04-15 08:23:24 -04:00
|
|
|
|
The change tries its best at maintaining backward compatibility, however
|
2020-04-13 19:07:59 -04:00
|
|
|
|
some edge cases won’t be covered, like `errors#first` will return `ActiveModel::Error` and manipulating
|
|
|
|
|
`errors.messages` and `errors.details` hashes directly will have no effect. Moving forward,
|
2019-04-28 08:25:51 -04:00
|
|
|
|
please convert those direct manipulations to use provided API methods instead.
|
|
|
|
|
|
2020-01-14 11:17:23 -05:00
|
|
|
|
The list of deprecated methods and their planned future behavioral changes at the next major release are:
|
|
|
|
|
|
|
|
|
|
* `errors#slice!` will be removed.
|
|
|
|
|
* `errors#each` with the `key, value` two-arguments block will stop working, while the `error` single-argument block would return `Error` object.
|
|
|
|
|
* `errors#values` will be removed.
|
|
|
|
|
* `errors#keys` will be removed.
|
|
|
|
|
* `errors#to_xml` will be removed.
|
|
|
|
|
* `errors#to_h` will be removed, and can be replaced with `errors#to_hash`.
|
|
|
|
|
* Manipulating `errors` itself as a hash will have no effect (e.g. `errors[:foo] = 'bar'`).
|
|
|
|
|
* Manipulating the hash returned by `errors#messages` (e.g. `errors.messages[:foo] = 'bar'`) will have no effect.
|
|
|
|
|
* Manipulating the hash returned by `errors#details` (e.g. `errors.details[:foo].clear`) will have no effect.
|
|
|
|
|
|
2019-04-28 08:25:51 -04:00
|
|
|
|
*lulalala*
|
2019-11-23 19:20:00 -05:00
|
|
|
|
|
2020-04-15 08:23:24 -04:00
|
|
|
|
|
2019-04-24 15:57:14 -04:00
|
|
|
|
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activemodel/CHANGELOG.md) for previous changes.
|