Ruby on Rails: Is there a way to make blank form inputs submit nil? [duplicate]
Possible Duplicate:
Make blank params[] nil
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.
Check out the attribute_normalizer plugin.
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?
精彩评论