File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -332,6 +332,19 @@ So for the example above, the key would be:
332332
333333 my_app_people_ssn
334334
335+ ### Encrypting without Saving
336+ Normally, vault-rails will wait until the after_save callback to encrypt changed
337+ values before updating them. If you' d like to encrypt changed attributes without
338+ saving, call ` vault_encrypt_attributes!`
339+
340+ ` ` ` ruby
341+ p = Person.new(ssn: "123-45-6789")
342+ p.ssn_encrypted
343+ > nil
344+ p.vault_encrypt_attributes!
345+ p.ssn_encrypted
346+ > "vault:dev:flu/yp9oeYYFgjcZH2hVBA=="
347+ ` ` `
335348
336349# ## Searching Encrypted Attributes
337350Because each column is uniquely encrypted, it is not possible to search for a
@@ -345,7 +358,6 @@ Person.where(ssn: "123-45-6789")
345358This is because the database is unaware of the plain- text data (which is part of
346359the security model).
347360
348-
349361Development
350362-----------
351363↥ [back to top](# table-of-contents)
You can’t perform that action at this time.
0 commit comments