- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
-
Clear secure password cache if password is set to
nil
Before:
user.password = 'something' user.password = nil
user.password # => 'something'
Now:
user.password = 'something' user.password = nil
user.password # => nil
Markus Doits
-
Fix delegation in
ActiveModel::Type::Registry#lookup
andActiveModel::Type.lookup
Passing a last positional argument
{}
would be incorrectly considered as keyword argument.Benoit Daloze
-
Fix
to_json
afterchanges_applied
forActiveModel::Dirty
object.Ryuta Kamizono
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
-
Fix
to_json
forActiveModel::Dirty
object.Exclude +mutations_from_database+ attribute from json as it lead to recursion.
Anil Maurya
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
-
Pass in
base
instead ofbase_class
to Error.human_attribute_nameThis 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 animal = Animal.new animal.freeze animal.age = 25 # => FrozenError, "can't modify a frozen Animal"
Josh Brody
-
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
’serrors
collection is now an array of these Error objects, instead of messages/details hash.For each of these
Error
object, itsmessage
andfull_message
methods are for generating error messages. Itsdetails
method would return error’s extra parameters, found in the originaldetails
hash.The change tries its best at maintaining backward compatibility, however some edge cases won’t be covered, like
errors#first
will returnActiveModel::Error
and manipulatingerrors.messages
anderrors.details
hashes directly will have no effect. Moving forward, please convert those direct manipulations to use provided API methods instead. Please note thaterrors#add
now acceptsoptions
as keyword arguments instead ofHash
which introduced a change in Ruby 3 to keyword arguments.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 thekey, value
two-arguments block will stop working, while theerror
single-argument block would returnError
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 witherrors#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.
lulalala
Please check 6-0-stable for previous changes.