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

Problem with blanks and nils with unique indexes #2099

Closed
justin808 opened this issue Oct 24, 2014 · 2 comments
Closed

Problem with blanks and nils with unique indexes #2099

justin808 opened this issue Oct 24, 2014 · 2 comments
Milestone

Comments

@justin808
Copy link

rails_admin is creating new records with "" (empty string) rather than nil, and for a column where there is a unique index, allowing for nil, then this leads to a non-unique index violation, as the second record with a "" is reported as not unique.

@williantenfen
Copy link

There could be a suggestion to use a gem like strip_attributes or auto_strip_attributes, and configure at models to strip the attributes that can be null. For me this solution worked fine . =D @justin808
But of course i had to check all attributes.

@wallace
Copy link

wallace commented Aug 16, 2015

👍

@mshibuya mshibuya added this to the 2.0.0 milestone May 22, 2019
mshibuya added a commit that referenced this issue Aug 4, 2019
By default, empty strings passed into nullable columns get converted to nils.
You can disable that conversion by setting `treat_empty_as_nil false`.
Refs. #2099, Fixes #3172
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

No branches or pull requests

4 participants