Skip to content

Instantly share code, notes, and snippets.

@henrik
henrik / nullify_blank_attributes.rb
Created November 27, 2010 10:11
ActiveRecord mixin to save NULL instead of empty strings to database.
module NullifyBlankAttributes
def write_attribute(attr_name, value)
new_value = value.presence
super(attr_name, new_value)
end
end