root/vendor/plugins/empty_fields_to_null/lib/empty_fields_to_null.rb @ b689e231
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
|