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

Skip default validations and blank string escape hatch #746

Merged
merged 2 commits into from
Oct 16, 2021
Merged

Conversation

jwoertink
Copy link
Member

Fixes #410

This PR adds in a new escape hatch that allows you to store a blank string. This should only be used in cases where you may have a legacy DB with empty strings stored or some case like that.

… and allow blank strings to be saved. Could be used for legacy DBs. Fixes #410
skip_default_validations

before_save do
body.allow_blank = true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't explicitly specify this, then your value will still get converted to nil when blank, and then Postgres will complain to you and null constraint violations.

@jwoertink jwoertink merged commit e19f67c into master Oct 16, 2021
@jwoertink jwoertink deleted the issues/410 branch October 16, 2021 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

valid? rejects any attribute that is an empty string.
1 participant