Description
i had a look at https://github.com/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://github.com/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://github.com/carchrae/localize_input/blob/master/lib/localize_input.rb#L14