I have to write a script that replace existing data with dummy (but valid) data. The script should only populate fields that are already populated on each record. I should NOT put dummy data into fields where no data existed previously. Can any one help to create a script?
I am using attr_encrypted
, i wold like to overwrite the existing data with new data, using a new key. How can i do this?
My sample code for your reference:
License.where.not(license_number: nil).each do |number|
number.update_attribute(:license_number, Faker::Number.number(6))
end
When trying to update, i am getting OpenSSL::Cipher::CipherError: bad decrypt
error
I believe it is due to the fact that attr_encrypted
tries to decrypt
first - which clearly won't work due to the key is different. Any idea is there to write the new data and iv
with a new a new key?