Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails' Active Record Encryption: Does not work #561

Closed
john-999 opened this issue Mar 24, 2022 · 1 comment
Closed

Rails' Active Record Encryption: Does not work #561

john-999 opened this issue Mar 24, 2022 · 1 comment

Comments

@john-999
Copy link

john-999 commented Mar 24, 2022

Context

Gem version: mobility (1.2.6)
Backend used: Table Backend (like Globalize)

Expected Behavior

Rails' Active Record Encryption (https://guides.rubyonrails.org/active_record_encryption.html) should work.

Actual Behavior

Rails' Active Record Encryption does not work:

class User < ApplicationRecord
  extend Mobility
  translates :name

  encrypts :name, deterministic: true, ignore_case: true
end

irb(main):001:0> User.new()

...throws the error:

gems/activerecord-7.0.2.3/lib/active_record/encryption/encryptable_record.rb:99:in `preserve_original_encrypted':
To use :ignore_case for 'name' you must create an additional column named 'original_name'
(ActiveRecord::Encryption::Errors::Configuration)

However, the column named original_name is present in the table user_translations.

If in the Model User.rb, I then comment out the option ignore_case: true, then a new (valid) object is saved (User.create(name: 'Hulk')) without any errors, but the attribute that is supposed to be encrypted (:name), is stored in clear text (the encryption directive is simply ignored).

@shioyama
Copy link
Owner

shioyama commented May 2, 2022

As with many other things, Mobility can't make the "magic" work by default. This doesn't work because it would require special treatment, possibly for each backend.

I'm closing, this is not a bug but a feature request.

@shioyama shioyama closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants