Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ActiveModel-style (Rails 3) `errors.to_json` for your Rails 2 app
module ActiveRecord
class Errors
def to_json
inject({}) { |hash, error|
attribute, message = error
hash[attribute] ||= []
hash[attribute] << message
hash
}.to_json
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment