From 2aaff4f6eb619b9719075f8d4d2cfcf5c201b3fc Mon Sep 17 00:00:00 2001 From: Samuel Kadolph Date: Thu, 17 Jun 2010 13:27:40 -0400 Subject: [PATCH] fixed ActiveModel::Errors#to_json output [#4890 state:resolved] --- activemodel/CHANGELOG | 1 + activemodel/lib/active_model/errors.rb | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/activemodel/CHANGELOG b/activemodel/CHANGELOG index a5e7f30..6f0aa0b 100644 --- a/activemodel/CHANGELOG +++ b/activemodel/CHANGELOG @@ -1,6 +1,7 @@ *Rails 3.0.0 [beta 4] (June 8th, 2010)* * JSON supports a custom root option: to_json(:root => 'custom') #4515 [Jatinder Singh] +* Correct output from ActiveModel::Errors#to_json #4890 [Samuel Kadolph] *Rails 3.0.0 [beta 3] (April 13th, 2010)* diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index f4c7400..8849e61 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -172,6 +172,8 @@ module ActiveModel to_a.each { |error| e.error(error) } end end + + def as_json(options = nil) to_a end #:nodoc: # Adds +message+ to the error messages on +attribute+, which will be returned on a call to # on(attribute) for the same attribute. More than one error can be added to the same -- 1.7.0.2.msysgit.0