-
Notifications
You must be signed in to change notification settings - Fork 28
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
Auto strip attributes...automatically? #33
Comments
Couldn't you include that module in the ApplicationRecord class so that every model would have it automatically by inheritance? No need to have it as a configuration option if its still just a small piece of code in a single file? Although that seems like an elegant way to do that. In that sense if it works with ApplicationRecord it might be good to add to wiki for others to copypaste. I don't think having all texts stripped by default is a good start although it works for many projects. Personally I wan't to specify stripping only happening on user inputs. Having something magic happening to texts that are only machine processed might cause making or missing some bugs. |
Can't remember from the top of my head, but I think |
Doing things automatically seems aligned with a gem named |
In my project I added this to
I haven't yet figured out how to make this apply to external models (such as It still would be nice to perhaps define that extension in this gem and document how to use it effectively. To echo what @pboling said, it would put a little more emphasis on the |
Update on my solution; I decided to put it in a concern and include it into specific models where I needed it. Obviously I used extra options that work with my particular application.
I wonder if a good API for this is just a kwarg for |
How do you feel about having a documented approach to apply it to multiple models in a few different ways? For example:
The third bullet could be a use case when you're using Markdown. It supports adding 2 trailing spaces as valid syntax to add a |
Yea having those in wiki (and a link in the front readme) would probably be most elegant way to do it? I guess anyone can create a new wiki page and a pull request to add a link. btw. that Markdown example is a good addition on why adding automatically can cause some bugs. |
I have similar issue like @skandragon in #4: "strip all non-serialized text and string fields"
I want all of the string columns to be stripped automatically.
This is what I came up with:
I'd prefer if this would be a configuration option so that I don't need to include this in every model.
Why? I think it's a good developer experience. Just like how I don't have to do many other things that come by default with rails (I don't have to convert
"1"
to1
for integer columns, checkbox => boolean, etc.)It would be great if this functionality came with rails for those of us who are spoiled by rails. :) ...but it doesn't
If it's a configuration option, it shouldn't bother users who don't want to use this, while it would make my life easier and I'd probably include this gem in every rails project of mine.
The text was updated successfully, but these errors were encountered: