diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2010-04-10 00:48:24 +1000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-04-10 13:21:20 +0200 |
commit | d748cc3cd07c6931e5ebc5242f268f1f7ec3d906 (patch) | |
tree | 287c3ff45d6f2b8cbffa813342d4dd1d04db7914 /activemodel/lib | |
parent | 944637648c9399391c6e790740a01eeeac620a5f (diff) | |
download | rails-d748cc3cd07c6931e5ebc5242f268f1f7ec3d906.tar.gz rails-d748cc3cd07c6931e5ebc5242f268f1f7ec3d906.tar.bz2 rails-d748cc3cd07c6931e5ebc5242f268f1f7ec3d906.zip |
Re-define empty? for errors to check if the values inside the OrderedHash are empty rather than the OrderedHash itself. [#4356 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 5 |
1 files changed, 5 insertions, 0 deletions
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") |