From 17ff856eda5f4b5de5c300179901e7ad1ad07ff3 Mon Sep 17 00:00:00 2001 From: priyankatapar Date: Fri, 20 Dec 2019 15:27:46 +0530 Subject: [PATCH] Binary type for attribute was getting override to Value type for 5.1 due to this. --- lib/attr_encrypted/adapters/active_record.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/attr_encrypted/adapters/active_record.rb b/lib/attr_encrypted/adapters/active_record.rb index a22108e4..e9e29a96 100644 --- a/lib/attr_encrypted/adapters/active_record.rb +++ b/lib/attr_encrypted/adapters/active_record.rb @@ -51,7 +51,10 @@ def attr_encrypted(*attrs) super options = attrs.extract_options! attr = attrs.pop - attribute attr if ::ActiveRecord::VERSION::STRING >= "5.1.0" + if ::ActiveRecord::VERSION::STRING >= "5.1.0" + column_type = columns_hash[attr.to_s].type unless columns_hash[attr.to_s].nil? + column_type.nil? ? attribute(attr) : attribute(attr, column_type) + end options.merge! encrypted_attributes[attr] define_method("#{attr}_was") do