diff options
Diffstat (limited to 'activemodel/CHANGELOG.md')
-rw-r--r-- | activemodel/CHANGELOG.md | 137 |
1 files changed, 107 insertions, 30 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 8d22e3ac46..a3368cd197 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,52 +1,129 @@ -* Validate options passed to `ActiveModel::Validations.validate`. +* Validate multiple contexts on `valid?` and `invalid?` at once. - Preventing, in many cases, the simple mistake of using `validate` instead of `validates`. + Example: - *Sonny Michaud* + class Person + include ActiveModel::Validations -* Deprecate `reset_#{attribute}` in favor of `restore_#{attribute}`. + attr_reader :name, :title + validates_presence_of :name, on: :create + validates_presence_of :title, on: :update + end - These methods may cause confusion with the `reset_changes` that behaves differently - of them. + person = Person.new + person.valid?([:create, :update]) # => false + person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]} -* Deprecate `ActiveModel::Dirty#reset_changes` in favor of `#clear_changes_information`. + *Dmitry Polushkin* - This method name is causing confusion with the `reset_#{attribute}` - methods. While `reset_name` set the value of the name attribute for the - previous value `reset_changes` only discard the changes and previous - changes. +* Add case_sensitive option for confirmation validator in models. -* Added `restore_attributes` method to `ActiveModel::Dirty` API to restore all the - changed values to the previous data. + *Akshat Sharma* - *Igor G.* +* Ensure `method_missing` is called for methods passed to + `ActiveModel::Serialization#serializable_hash` that don't exist. -* Allow proc and symbol as values for `only_integer` of `NumericalityValidator` + *Jay Elaraj* - *Robin Mehner* +* Remove `ActiveModel::Serializers::Xml` from core. -* `has_secure_password` now verifies that the given password is less than 72 - characters if validations are enabled. + *Zachary Scott* - Fixes #14591. +* Add `ActiveModel::Dirty#[attr_name]_previously_changed?` and + `ActiveModel::Dirty#[attr_name]_previous_change` to improve access + to recorded changes after the model has been saved. - *Akshay Vishnoi* + It makes the dirty-attributes query methods consistent before and after + saving. -* Remove deprecated `Validator#setup` without replacement. + *Fernando Tapia Rico* - See #10716. +* Deprecate the `:tokenizer` option for `validates_length_of`, in favor of + plain Ruby. - *Kuldeep Aggarwal* + *Sean Griffin* -* Add plural and singular form for length validator's default messages. +* Deprecate `ActiveModel::Errors#add_on_empty` and `ActiveModel::Errors#add_on_blank` + with no replacement. - *Abd ar-Rahman Hamid* + *Wojciech Wnętrzak* -* Introduce `validate` as an alias for `valid?`. +* Deprecate `ActiveModel::Errors#get`, `ActiveModel::Errors#set` and + `ActiveModel::Errors#[]=` methods that have inconsistent behavior. - This is more intuitive when you want to run validations but don't care about - the return value. + *Wojciech Wnętrzak* - *Henrik Nyh* +* Allow symbol as values for `tokenize` of `LengthValidator`. -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activemodel/CHANGELOG.md) for previous changes. + *Kensuke Naito* + +* Assigning an unknown attribute key to an `ActiveModel` instance during initialization + will now raise `ActiveModel::AttributeAssignment::UnknownAttributeError` instead of + `NoMethodError`. + + Example: + + 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. + + Example: + + 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. + + Example: + + class User < ActiveRecord::Base + validates :name, presence: true + end + + 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 + accept: true. + +* Remove deprecated `ActiveModel::Dirty#reset_#{attribute}` and + `ActiveModel::Dirty#reset_changes`. + + *Rafael Mendonça França* + +* Change the way in which callback chains can be halted. + + The preferred method to halt a callback chain from now on is to explicitly + `throw(:abort)`. + In the past, returning `false` in an Active Model `before_` callback had + the side effect of halting the callback chain. + This is not recommended anymore and, depending on the value of the + `ActiveSupport.halt_callback_chains_on_return_false` option, will + either not work at all or display a deprecation warning. + + +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md) for previous changes. |