When AR objects are saved, empty fields are saved as '' instead of nil.
- Complicates queries for empty fields (
WHERE field IS NULL OR field = '')
- Makes the use of
unless field.blank?necessary (opposed to only
- Can lead to late-detected bugs because most of the time strings were
filled or ''and suddenly they are
- Some validations do not support
- Databases can handle
NULLbetter & faster than empty strings (especially when using
Defines an AR
before_validation that sets empty Strings to nil.
script/plugin install git://github.com/collectiveidea/clear_empty_attributes.git
sudo gem install clear_empty_attributes
When you are switching to
clear_empty_attributes, run this task
to remove any
'' strings/texts from your database.
(only works when checked out or installed as plugin)
Hereby placed under public domain, do what you want, just do not hold anybody accountable...