Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace localize_input with delocalize gem #613

Open
carchrae opened this issue Jan 18, 2019 · 0 comments
Open

replace localize_input with delocalize gem #613

carchrae opened this issue Jan 18, 2019 · 0 comments
Labels
tech debt technical debt

Comments

@carchrae
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech debt technical debt
Projects
None yet
Development

No branches or pull requests

2 participants