Pass in base instead of base_class to Error.human_attribute_name
This is useful in cases where the human_attribute_name method depends
on other attributes' values of the class under validation to derive what the
attribute name should be.
Filipe Sabella
Deprecate marshalling load from legacy attributes format.
Ryuta Kamizono
*_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
Raise FrozenError when trying to write attributes that aren't backed by the database on an object that is frozen:
class Animal
include ActiveModel::Attributes
attribute :age
end
Add *_previously_was attribute methods when dirty tracking. Example:
pirate.update(catchphrase: "Ahoy!")
pirate.previous_changes["catchphrase"] # => ["Thar She Blows!", "Ahoy!"]
pirate.catchphrase_previously_was # => "Thar She Blows!"
DHH
Encapsulate each validation error as an Error object.
The ActiveModel’s errors collection is now an array of these Error
objects, instead of messages/details hash.
For each of these Error object, its message and full_message methods
are for generating error messages. Its details method would return error’s
extra parameters, found in the original details hash.
The change tries its best at maintaining backward compatibility, however
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,
please convert those direct manipulations to use provided API methods instead.
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.
Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.
All Depfu comment commands
@depfu rebase
Rebases against your default branch and redoes this update
@depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@depfu close
Closes this PR and deletes the branch
@depfu reopen
Restores the branch and reopens this PR (if it's closed)
@depfu pause
Ignores all future updates for this dependency and closes this PR
@depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)
Here is everything you need to know about this upgrade. Please take a good look at what changed and the test results before merging this pull request.
What changed?
✳️ activemodel (>= 5.1, < 6.1 → >= 5.1, <= 6.1.0) · Repo · Changelog
Release Notes
6.1.0 (from changelog)
Does any of this look wrong? Please let us know.
Commits
See the full diff on Github. The new version differs by more commits than we can show here.
Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with
@depfu rebase
.All Depfu comment commands