Skip to content

Commit

Permalink
Update docs and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
djmb committed Aug 22, 2024
1 parent 6a27e7b commit 01022d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
10 changes: 10 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
* Deserialize database values before decryption

PostgreSQL binary values (`ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bytea)
need to be deserialized before they are decrypted.

Additionally ensure that the order of serialization/deserialization is consistent
for `serialize :foo` and `encrypts :foo` whichever order they are declared in.

*Donal McBreen*

* Infer default `:inverse_of` option for `delegated_type` definitions.

```ruby
Expand Down
16 changes: 1 addition & 15 deletions guides/source/active_record_encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,7 @@ To encrypt Action Text fixtures, you should place them in `fixtures/action_text/

`active_record.encryption` will serialize values using the underlying type before encrypting them, but, unless using a custom `message_serializer`, *they must be serializable as strings*. Structured types like `serialized` are supported out of the box.

If you need to support a custom type, the recommended way is using a [serialized attribute](https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Serialization/ClassMethods.html). The declaration of the serialized attribute should go **before** the encryption declaration:

```ruby
# CORRECT
class Article < ApplicationRecord
serialize :title, type: Title
encrypts :title
end
# INCORRECT
class Article < ApplicationRecord
encrypts :title
serialize :title, type: Title
end
```
If you need to support a custom type, the recommended way is using a [serialized attribute](https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Serialization/ClassMethods.html).

### Ignoring Case

Expand Down

0 comments on commit 01022d0

Please sign in to comment.