Skip to content

Commit c06c8ae

Browse files
committed
Update README.md
1 parent 82d8b42 commit c06c8ae

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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
337350
Because each column is uniquely encrypted, it is not possible to search for a
@@ -345,7 +358,6 @@ Person.where(ssn: "123-45-6789")
345358
This is because the database is unaware of the plain-text data (which is part of
346359
the security model).
347360

348-
349361
Development
350362
-----------
351363
↥ [back to top](#table-of-contents)

0 commit comments

Comments
 (0)