I’m using ActiveAdmin and if I edit an entry and leave a TEXT field blank, in the db it gets set as empty string — when it really should be getting set as NULL (and NULL is allowed on the schema for those fields).
Has anyone else encountered this issue and solved it?
(Moved from comments, as I found more and more to say about it):
I haven’t used ActiveAdmin, but… Any reason why an empty string wouldn’t be stored as an empty string but a NULL?
I think the empty-string-to-Nil conversion should never be automatic, since it violates least surprise. I’d appreciate a doc reference stating the opposite if I’m wrong…
As for solving it, I’d guess this might do the trick:
Or, more systemic, this gem.