Is there a way to make blank form inputs submit nil? Right now, I'm going through and in a before_save manually converting all "" into nil.
This really doesn't seem very DRY, and I feel like I must be missing something.
Is there a way to make blank form inputs submit nil? Right now, I'm going through and in a before_save manually converting all "" into nil.
This really doesn't seem very DRY, and I feel like I must be missing something.
I don't know if that is what you already do but look at this thread. The accepted answer seems as DRY as it gets for this problem.
There is no notion of "submitting nil" from a browser.
If field of name 'foo' is not submitted, then if you ask for params[:foo], it will return nil, which seems to be the behavior you desire.
Can you explain more what you want to do?