Cast a value to a type that the database understands. For example,
SQLite does not understand dates, so this method will convert a Date to a String.
# File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 24
def type_cast(value, column = nil)
value = id_value_for_database(value) if value.is_a?(Base)
if column
value = type_cast_from_column(column, value)
end
_type_cast(value)
rescue TypeError
to_type = column ? " to #{column.type}" : ""
raise TypeError, "can't cast #{value.class}#{to_type}"
end