Skip to content

Commit 31ba84d

Browse files
authored
Ensure binary encoding check is performed with the correct context in #encrypt_as_text (rails#51423)
1 parent fc9ccbd commit 31ba84d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

activerecord/lib/active_record/encryption/encrypted_attribute_type.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ def serialize_with_current(value)
134134
end
135135

136136
def encrypt_as_text(value)
137-
if encryptor.binary? && !cast_type.binary?
138-
raise Errors::Encoding, "Binary encoded data can only be stored in binary columns"
139-
end
140-
141137
with_context do
138+
if encryptor.binary? && !cast_type.binary?
139+
raise Errors::Encoding, "Binary encoded data can only be stored in binary columns"
140+
end
141+
142142
encryptor.encrypt(value, **encryption_options)
143143
end
144144
end

0 commit comments

Comments
 (0)