Sha256: 610566347281865e44f46eedb1aaf80e4aab1e3683a524e1d5393320acb27d8f

Contents?: true

Size: 350 Bytes

Versions: 1

Compression:

Stored size: 350 Bytes

Contents

module Dorsale::ActiveRecordCommaTypeCast
  def cast_value(value)
    if value.is_a?(String)
      super value.gsub(",", ".").gsub(/[^-0-9\.]/, "")
    else
      super value
    end
  end
end

ActiveRecord::Type::Decimal.send(:prepend, Dorsale::ActiveRecordCommaTypeCast)
ActiveRecord::Type::Float.send(:prepend, Dorsale::ActiveRecordCommaTypeCast)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dorsale-3.4.0 lib/dorsale/active_record_comma_type_cast.rb