Sha256: 50af88afbfe67f1e9db9fca2e400967eebf6412a1e401bd1ba5cded6bf2d5f2c

Contents?: true

Size: 490 Bytes

Versions: 5

Compression:

Stored size: 490 Bytes

Contents

module Tuning
  module Extensions
    module ActiveRecord
      module Base
        extend ActiveSupport::Concern

        included do
          before_save :nilify_blank_attributes
          alias_method :validate, :valid?
        end

        private

        def nilify_blank_attributes
          attributes.each do |column, value|
            if value.is_a? String and value.blank?
              self[column] = nil
            end
          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tuning-4.0.1.1 lib/tuning/extensions/active_record/base.rb
tuning-4.0.1.0 lib/tuning/extensions/active_record/base.rb
tuning-4.0.0.1 lib/tuning/extensions/active_record/base.rb
tuning-4.0.0.0 lib/tuning/extensions/active_record/base.rb
tuning-1.0.0 lib/tuning/extensions/active_record/base.rb