Revert "Fix generation of wrong json string when field has multiple errors"

This reverts commit a9b666b51d.
This commit is contained in:
José Valim 2010-12-01 11:42:30 +01:00
parent ba63c0a9b5
commit 1ec126dd37
2 changed files with 0 additions and 20 deletions

View File

@ -167,16 +167,6 @@ module ActiveModel
def as_json(options=nil)
self
end
def encode_json(encoder)
errors = []
each_pair do |key, value|
value = value.first if value.size == 1
errors << "#{encoder.encode(key.to_s)}:#{encoder.encode(value, false)}"
end
"{#{errors * ','}}"
end
# Adds +message+ to the error messages on +attribute+, which will be returned on a call to
# <tt>on(attribute)</tt> for the same attribute. More than one error can be added to the same

View File

@ -61,15 +61,5 @@ class ErrorsTest < ActiveModel::TestCase
assert_equal ["name can not be blank", "name can not be nil"], person.errors.to_a
end
test 'to_json should return valid json string' do
person = Person.new
person.errors.add(:name, "can not be blank")
person.errors.add(:name, "can not be nil")
hash = ActiveSupport::OrderedHash[:name, ["can not be blank", "can not be nil"]]
assert_equal person.errors.to_json, hash.to_json
end
end