aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type/string.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/type/string.rb')
-rw-r--r--activerecord/lib/active_record/type/string.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/type/string.rb b/activerecord/lib/active_record/type/string.rb
index 14b03dcb2d..e1791169d8 100644
--- a/activerecord/lib/active_record/type/string.rb
+++ b/activerecord/lib/active_record/type/string.rb
@@ -16,10 +16,12 @@ module ActiveRecord
end
def type_cast_for_database(value)
- if value.is_a?(::String)
- ::String.new(value)
- else
- super
+ case value
+ when ::Numeric, ActiveSupport::Duration then value.to_s
+ when ::String then ::String.new(value)
+ when true then "1"
+ when false then "0"
+ else super
end
end