Skip to content

Commit a2a399c

Browse files
authored
Merge pull request rails#43021 from basecamp/encryption-lenght-validation
Minor improvements to Encryptable records
2 parents 6ec669b + 6eb4ee4 commit a2a399c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

activerecord/lib/active_record/encryption/encryptable_record.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ module EncryptableRecord
4646
# encryption is used, they will be used to generate additional ciphertexts to check in the queries.
4747
def encrypts(*names, key_provider: nil, key: nil, deterministic: false, downcase: false, ignore_case: false, previous: [], **context_properties)
4848
self.encrypted_attributes ||= Set.new # not using :default because the instance would be shared across classes
49+
scheme = scheme_for key_provider: key_provider, key: key, deterministic: deterministic, downcase: downcase, \
50+
ignore_case: ignore_case, previous: previous, **context_properties
4951

5052
names.each do |name|
51-
scheme = scheme_for key_provider: key_provider, key: key, deterministic: deterministic, downcase: downcase, \
52-
ignore_case: ignore_case, previous: previous, **context_properties
5353
encrypt_attribute name, scheme
5454
end
5555
end
@@ -133,7 +133,7 @@ def add_length_validation_for_encrypted_columns
133133
end
134134

135135
def validate_column_size(attribute_name)
136-
if table_exists? && limit = columns_hash[attribute_name.to_s]&.limit
136+
if limit = columns_hash[attribute_name.to_s]&.limit
137137
validates_length_of attribute_name, maximum: limit
138138
end
139139
end

0 commit comments

Comments
 (0)