mercredi 17 novembre 2021

attr_encrypted gem sometimes saving null value in database

I am running rails 3 version and using attr_encrypted gem version '1.2.1' . sometimes i have seen that nil entry is getting stored into column encrypted_private_key.

Below is my model

class Device < ActiveRecord::Base
  attr_encrypted :private_key, :key => proc {|device| device.log }
end

Below is how i am trying to store value in column encrypted_private_key

device = Device.new
device.private_key = "XYZ" 
device.save

after doing device.save if i do device.encrypted_private_key then sometimes i am getting nil value. what could be the reason for this? This issue is not coming everytime but sometime.

Aucun commentaire:

Enregistrer un commentaire