This project is archived and is in readonly mode.
Rails 3RC's ActiveModel#as_json outputs array of message instead of hash of columns and messages
-
Alex Le
Hi José,
Here's the patch for this issue. Basically now the ActiveModel::Errors#as_json would return the OrderedHash object itself, which will take care of the json serialization itself.
So far I got the activemodel test suite to pass 100%, but the activerecord test suite failed at 3 places. However I think it's more or less because of my machine lacking the proper language support. The failing tests in the activerecord suite are: test_validate_case_insensitive_uniqueness, test_validate_uniqueness, and test_validate_uniqueness_with_limit_and_utf8, none of which relate to the json serialization.
This is my first time patching Rails, so if I missed something, please let me know.
Cheers!
Alex
-
José Valim
Congratulations on your first patch! From what I saw, it looks great. I will try to apply it during next week. Thanks!
-
Repository
- State changed from new to resolved
(from [aeaab06c79a9e3cfa9988270847fa8c6f863570a]) ActiveModel::Errors json serialization to work as Rails 3b4 [#5254 Rails 3RC's ActiveModel#as_json outputs array of message instead of hash of c... state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/aeaab06c79a9e3cfa9988270847fa8... -
Adam Meehan
This issue needs a little more thought. For example if we have multiple errors for an attribute we get a JSON hash with duplicate keys of the attribute name.
-
Adam Meehan
See here for my patch
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...
