From d748cc3cd07c6931e5ebc5242f268f1f7ec3d906 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Sat, 10 Apr 2010 00:48:24 +1000 Subject: Re-define empty? for errors to check if the values inside the OrderedHash are empty rather than the OrderedHash itself. [#4356 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activemodel/lib/active_model/errors.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activemodel/lib/active_model/errors.rb') diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 64b28f6def..e6c86c7843 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -142,6 +142,11 @@ module ActiveModel to_a.size end + # Returns true if there are any errors, false if not. + def empty? + all? { |k, v| v && v.empty? } + end + # Returns an xml formatted representation of the Errors hash. # # p.errors.add(:name, "can't be blank") -- cgit v1.2.3