From 2e70f44123cb6fab9124b52a6cc02ff453b8397f Mon Sep 17 00:00:00 2001 From: Henrik Nyh Date: Sun, 23 Mar 2014 12:09:55 +0100 Subject: ActiveRecord/ActiveModel '#validate' alias for 'valid?' It's unintuitive to call '#valid?' when you want to run validations but don't care about the return value. The alias in ActiveRecord isn't strictly necessary (the ActiveModel alias is still in effect), but it clarifies. --- activemodel/lib/active_model/validations.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index e9674d5143..cf97f45dba 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -285,6 +285,8 @@ module ActiveModel # Runs all the specified validations and returns +true+ if no errors were # added otherwise +false+. # + # Aliased as validate. + # # class Person # include ActiveModel::Validations # @@ -319,6 +321,8 @@ module ActiveModel self.validation_context = current_context end + alias_method :validate, :valid? + # Performs the opposite of valid?. Returns +true+ if errors were # added, +false+ otherwise. # -- cgit v1.2.3