Created
January 27, 2011 13:13
-
-
Save olivernn/798486 to your computer and use it in GitHub Desktop.
stop invalid json after calling to_json on active model errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveModel | |
class Errors | |
def as_json(options=nil) | |
self | |
to_hash | |
end | |
def to_hash | |
hash = ActiveSupport::OrderedHash.new | |
each { |k, v| (hash[k] ||= []) << v } | |
hash | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment