diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-09 16:13:48 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-09 16:13:48 -0300 |
commit | ddb0b4a474de99fa8474e2111a05dd4bba7c6f0e (patch) | |
tree | 504334562aa90a23f286616fcb36604628182e06 /activerecord/lib/active_record/type/binary.rb | |
parent | 19f1cfbb03f8230f5d30cc91c41c3f719813da9d (diff) | |
parent | c93dbfef36c9b095121650beec2362de42d6b715 (diff) | |
download | rails-ddb0b4a474de99fa8474e2111a05dd4bba7c6f0e.tar.gz rails-ddb0b4a474de99fa8474e2111a05dd4bba7c6f0e.tar.bz2 rails-ddb0b4a474de99fa8474e2111a05dd4bba7c6f0e.zip |
Merge pull request #15591 from sgrif/sg-rm-write-attribute
Make `_before_type_cast` actually be before type cast
Diffstat (limited to 'activerecord/lib/active_record/type/binary.rb')
-rw-r--r-- | activerecord/lib/active_record/type/binary.rb | 9 |
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 |