ankane / lockbox

Modern encryption for Ruby and Rails
MIT License
1.44k stars 68 forks source link

Missing keyword: :coder error for Rails 7.1 when using `has_encrypted :name, type: :array` #182

Closed eiskrenkov closed 8 months ago

eiskrenkov commented 9 months ago

Rails 7.1 introduced a new config field for active record - config.active_record.default_column_serializer when introducing "Allow to define the default column serializer" which is nil by default (see here).

Lockbox uses serialize active record api here, which checks for configured coder and raises an error if it's not here, which results in errors when using type: :array with Rails 7.1.x with its defaults.

Temporary solution is to use YAML serializer:

config/application.rb

# ...
config.active_record.default_column_serializer = YAML
# ...

but ideally it's needed to pass coder to serialize everywhere.

Moreover, lockbox tests are still passing because, as it seems, rails configuration is applied during booting process and lockbox tests aren't doing that

ankane commented 8 months ago

Hi @eiskrenkov, thanks for reporting! Fixed in the commit above.

eiskrenkov commented 8 months ago

Thank you so much for a quick reaction and the fix @ankane 😄

And also Merry Christmas and Happy new year 🎄🎄🎄

ankane commented 8 months ago

Thanks, you too!