Skip to content
Browse files

fix difference between behaviour of blank and empty

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent b7bb795 commit 05da7528474f0ff42ddbf23fb16ad777d9795d45 Hemant Kumar committed with josevalim
Showing with 7 additions and 1 deletion.
  1. +1 −1 activemodel/lib/active_model/errors.rb
  2. +6 −0 activemodel/test/cases/errors_test.rb
View
2 activemodel/lib/active_model/errors.rb
@@ -149,7 +149,7 @@ def count
def empty?
all? { |k, v| v && v.empty? }
end
-
+ alias_method :blank?, :empty?
# Returns an xml formatted representation of the Errors hash.
#
# p.errors.add(:name, "can't be blank")
View
6 activemodel/test/cases/errors_test.rb
@@ -25,7 +25,13 @@ def self.human_attribute_name(attr, options = {})
def self.lookup_ancestors
[self]
end
+ end
+ test "should return true if no errors" do
+ person = Person.new
+ person.errors[:foo]
+ assert person.errors.empty?
+ assert person.errors.blank?
end
test "method validate! should work" do

0 comments on commit 05da752

Please sign in to comment.
Something went wrong with that request. Please try again.