DmitryTsepelev / store_model

Work with JSON-backed attributes as ActiveRecord-ish models
MIT License
1.09k stars 89 forks source link

Attribute encryption with ActiveRecord::Encryption #149

Open stephen-tech4 opened 1 year ago

stephen-tech4 commented 1 year ago

Hi, I would like to ask if there is any support for the StoreModel attribute with rails ActiveRecord::Encryption.

class User
    attribute :contact_info, ContactInfo.to_type
end

class ContactInfo
    include StoreModel

    attribute :email, :string # Attribute to be encrypted

    encrypts :email, deterministic: true, ignore_case: true # From ActiveRecord::Encryption
end

Is there a way to encrypt only the user.contact_info.email?

DmitryTsepelev commented 1 year ago

Hey hey! I know it works fine with https://github.com/ankane/lockbox, but no one added support for rails encryption. So if you're interested in this functionality — please check what's needed to be done to make it work (I guess we just need to implement a couple of methods) and I'll be there ready to review PR or provide any other help 🙂