From 86e3b047ba0349bd88952d4e54504327c3f7e59c Mon Sep 17 00:00:00 2001 From: Dmitry Polushkin Date: Thu, 30 Jul 2015 09:58:46 +0100 Subject: Validate multiple contexts on `valid?` and `invalid?` at once. Example: ```ruby class Person include ActiveModel::Validations attr_reader :name, :title validates_presence_of :name, on: :create validates_presence_of :title, on: :update end person = Person.new person.valid?([:create, :update]) # => true person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]} ``` --- activemodel/CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'activemodel/CHANGELOG.md') diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index dddfd940bb..625dfa404b 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,3 +1,21 @@ +* Validate multiple contexts on `valid?` and `invalid?` at once. + + Example: + + class Person + include ActiveModel::Validations + + attr_reader :name, :title + validates_presence_of :name, on: :create + validates_presence_of :title, on: :update + end + + person = Person.new + person.valid?([:create, :update]) # => true + person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]} + + *Dmitry Polushkin* + * Ensure `method_missing` is called for methods passed to `ActiveModel::Serialization#serializable_hash` that don't exist. -- cgit v1.2.3