You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
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.
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:
irb(main):001:0>
User.new()
...throws the error:
However, the column named
original_name
is present in the tableuser_translations
.If in the Model
User.rb
, I then comment out the optionignore_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).The text was updated successfully, but these errors were encountered: