With the clear_empty_attributes plugin, all empty string worries are gone!
- Complicate queries for empty fields (
WHERE field IS NULL OR field = ''
) - Use of
unless field.blank?
(opposed to onlyif field
) - Late-detected bugs because most of the time columns were
filled or ''
and suddenly they arenil
- Some validations do not support
:allow_blank=>true
- Datebases can handle
NULL
better & faster than''
(especially when usingLIKE
)
Install
script/plugin install git://github.com/grosser/clear_empty_attributes.git
Now all empty strings will be saves as NULL.
Migrate
To take care of all other/old models we have to run a migration.
Remove any blank strings/texts from your Models:
rake clear_empty_attributes:clear_all_blank_strings MODELS=User,Movie,...