Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix difference between behaviour of blank and empty

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 8de5595e4d101a53f33ae8c48837855d8594f320 1 parent 5c66677
Hemant Kumar authored josevalim committed
View
2  activemodel/lib/active_model/errors.rb
@@ -147,7 +147,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
Please sign in to comment.
Something went wrong with that request. Please try again.