8 Matching Annotations
- Dec 2019
-
stackoverflow.com stackoverflow.com
-
Arguably, the rails-team's choice of raising ArgumentError instead of validation error is correct in the sense that we have full control over what options a user can select from a radio buttons group, or can select over a select field, so if a programmer happens to add a new radio button that has a typo for its value, then it is good to raise an error as it is an application error, and not a user error. However, for APIs, this will not work because we do not have any control anymore on what values get sent to the server.
-
liberal_enum :kind
-
-
stackoverflow.com stackoverflow.com
-
When the controller creates the user, instead of adding a validation error to the record, it raises an exception. How to avoid this?
-
I really dislike the reasoning as stated in the issue listed above. Since the value is coming over the wire, it should be treated the same as a freetext input where the expectation is to validate in the model and not the controller. This is especially true in APIs where the developers have even less of a say as far as expected input coming from form data (for example).
-
In case anyone wants a hack, here is what I came up with.
-
-
stackoverflow.com stackoverflow.com
-
But now the first line throws an exception ArgumentError: '0' is not a valid audience
-
- Nov 2019