aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type/binary.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/type/binary.rb')
-rw-r--r--activerecord/lib/active_record/type/binary.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/type/binary.rb b/activerecord/lib/active_record/type/binary.rb
index bc93f6e1bf..3bf29b5026 100644
--- a/activerecord/lib/active_record/type/binary.rb
+++ b/activerecord/lib/active_record/type/binary.rb
@@ -9,7 +9,16 @@ module ActiveRecord
true
end
+ def type_cast(value)
+ if value.is_a?(Data)
+ value.to_s
+ else
+ super
+ end
+ end
+
def type_cast_for_database(value)
+ return if value.nil?
Data.new(super)
end