diff options
Diffstat (limited to 'activemodel/CHANGELOG.md')
-rw-r--r-- | activemodel/CHANGELOG.md | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index fb4b972282..77386e5e41 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,7 +1,56 @@ +* Assigning an unknown attribute key to an `ActiveModel` instance during initialization + will now raise `ActiveModel::AttributeAssignment::UnknownAttributeError` instead of + `NoMethodError` + + ```ruby + User.new(foo: 'some value') + # => ActiveModel::AttributeAssignment::UnknownAttributeError: unknown attribute 'foo' for User. + ``` + + *Eugene Gilburg* + +* Extracted `ActiveRecord::AttributeAssignment` to `ActiveModel::AttributeAssignment` + allowing to use it for any object as an includable module + + ``` ruby + class Cat + include ActiveModel::AttributeAssignment + attr_accessor :name, :status + end + + cat = Cat.new + cat.assign_attributes(name: "Gorby", status: "yawning") + cat.name # => 'Gorby' + cat.status => 'yawning' + cat.assign_attributes(status: "sleeping") + cat.name # => 'Gorby' + cat.status => 'sleeping' + ``` + + *Bogdan Gusiev* + +* Add `ActiveModel::Errors#details` + + To be able to return type of used validator, one can now call `details` + on Errors instance: + + ```ruby + class User < ActiveRecord::Base + validates :name, presence: true + end + ``` + + ```ruby + user = User.new; user.valid?; user.errors.details + => {name: [{error: :blank}]} + ``` + + *Wojciech Wnętrzak* + * Change validates_acceptance_of to accept true by default. The default for validates_acceptance_of is now "1" and true. - In the past, only "1" was the default and you were required to add + In the past, only "1" was the default and you were required to add accept: true. * Remove deprecated `ActiveModel::Dirty#reset_#{attribute}` and |