This project is archived and is in readonly mode.
Support multiple errors per attribute in ActiveModel Errors JSON serialization
-
Adam Meehan
- Tag changed from activemodel to json encoding as_json, activemodel, errors, patch, serialization
-
Lake
+1 applies cleanly to master and the tests pass.
I'm running ruby 1.9.2.
-
Thilo Utke
- 1 for this.
-
Gert Goet
+1
-
Aditya Sanghi
- State changed from new to open
- Milestone cleared.
- Assigned user set to Santiago Pastorino
- Tag changed from json encoding as_json, activemodel, errors, patch, serialization to json encoding as_json, activemodel, errors, patch, serialization, verified
- Importance changed from to Medium
Patch applies! tests look fine and pass.
-
Thilo Utke
Hi I suggest a slightly different solution that fixes to_hash to return the ordered hash instead of self. So you get the expected behavior when calling to_hash and as_json can rely on to_hash. See patch for details.
-
Aditya Sanghi
@thilo yes your version makes better sense.
-
José Valim
Applied on master. Can we have a patch for 2-3-stable?
-
Repository
- State changed from open to resolved
(from [7148b933c4865a5140187d7ed792fd6df9b860a4]) ActiveModel::Errors.to_hash returns plain OrderedHash and used in to_json serialization to properly handle multiple errors per attribute [#5615 Support multiple errors per attribute in ActiveModel Errors JSON serialization state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
https://github.com/rails/rails/commit/7148b933c4865a5140187d7ed792f...
