Skip to content

Instantly share code, notes, and snippets.

@olivernn
Created January 27, 2011 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivernn/798486 to your computer and use it in GitHub Desktop.
Save olivernn/798486 to your computer and use it in GitHub Desktop.
stop invalid json after calling to_json on active model errors
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