title: Encrypted Date of birth is not being saved in database of sinatra/ rails
body: <p>Here is my code:</p>
  <p>patient_profile.rb</p>
  <pre><code>class PatientProfile &lt; ApplicationRecord
    belongs_to :patient
    ............
    attr_encrypted :dob, key: Base64.decode64(SECRET_KEY)
    validates_presence_of :dob
  end
  </code></pre>
  <p>db/migrate/20200618205840_patient_profiles.rb</p>
  <pre><code>class PatientProfiles &lt; ActiveRecord::Migration[6.0]
    def change
      create_table :user_profiles do |t|
        t.string :encrypted_gender
        t.string :encrypted_gender_iv
        t.string :encrypted_address
        t.string :encrypted_address_iv
        .....................
  
        t.date :encrypted_dob
        t.date :encrypted_dob_iv
        t.integer :patient_id, index: true
        t.timestamps
      end
    end
  end
  </code></pre>
  <p>patients_controller.rb</p>
  <pre><code>class PatientsController &lt; ApplicationController
    # POST /api/v1/signup
    post '/signup' do
    patient = Patient.new(params[:patient])
    patient.password = params[:patient][:password]
    patient.unique_code = SecureRandom.hex(6)
    patient.confirmation_token = (SecureRandom.random_number(9e4) + 1e4).to_i
    patient.confirmation_sent_at = Time.now
      if patient.save
        token = JsonWebToken.encode(patient_id: patient.id)
        send_email(patient,
               &quot;Account Verification&quot;,
               &quot;Your verification code is #{patient.confirmation_token}&quot;)
        response = { patient: patient_response(patient), token: token }
    [200, response.to_json]
    else
      halt 422, error_message(patient.errors.full_messages)
    end
    rescue ActiveRecord::RecordInvalid =&gt; error
    halt 422, error_message(error.message)
  end
  </code></pre>
  <p>In postman we can post date and it shows posted.
  But in database dob field is null.</p>
  <p>What's an issue with this?</p>
  <p>Thanks in advance.</p>
  <p>Here is log:</p>
  <p><a href="https://i.stack.imgur.com/ByjSN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ByjSN.png" alt="Here is my log" /></a></p>