You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i had a look at https:/clemens/delocalize#controller-setup - and i think it definitely the way to go. in fact, the whole idea that you sanitise inputs in the controller and not in the model is what had deeply bothered me about the current use of localize_input_of - which was being called every time a model value was set, regardless of if it was an external/user input or not (ie, it currently wastes a tremendous amount of effort doing pointless transforms). instead, doing it on controller parameters is a much saner way to handle this.
and the fun doesn't stop at localisation. https:/mdeering/attribute_normalizer works in the same fashion - on the model, causing much cpu cycles to be blown ensuring that already normalised values are normalised.
so - to actually do this right i think all this sanitising/normalising code should all move to controllers. but that is no small undertaking, so i'm going to suggest that this PR is merged as-is because it is a small/quick change but a huge improvement so at least the current code will not be applied to values that have already been transformed from a string into a number. https:/carchrae/localize_input/blob/master/lib/localize_input.rb#L14
i had a look at https:/clemens/delocalize#controller-setup - and i think it definitely the way to go. in fact, the whole idea that you sanitise inputs in the controller and not in the model is what had deeply bothered me about the current use of
localize_input_of
- which was being called every time a model value was set, regardless of if it was an external/user input or not (ie, it currently wastes a tremendous amount of effort doing pointless transforms). instead, doing it on controller parameters is a much saner way to handle this.and the fun doesn't stop at localisation. https:/mdeering/attribute_normalizer works in the same fashion - on the model, causing much cpu cycles to be blown ensuring that already normalised values are normalised.
so - to actually do this right i think all this sanitising/normalising code should all move to controllers. but that is no small undertaking, so i'm going to suggest that this PR is merged as-is because it is a small/quick change but a huge improvement so at least the current code will not be applied to values that have already been transformed from a string into a number. https:/carchrae/localize_input/blob/master/lib/localize_input.rb#L14
Originally posted by @carchrae in #611
The text was updated successfully, but these errors were encountered: