Project

General

Profile

Download (302 Bytes) Statistics
| Branch: | Tag: | Revision:
b689e231 Marc Dequènes (Duck)
module EmptyFieldsToNull
def self.included(base)
base.class_eval do
before_validation {|model| model.empty_fields_to_null }
end
end

def empty_fields_to_null
attributes.each do |key, value|
self[key] = nil if value.kind_of?(String) and value.length == 0
end
end
end