title: must specify an iv attr_encrypted, how to check login and password
body: <p>Hi have the following model:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  
       secret_key = ENV['DB_COL_ENCRYPTED_KEY']
       attr_encrypted :email, :key =&gt; secret_key
       attr_encrypted :password, :key =&gt; secret_key
       [...]
  end
  </code></pre>
  
  <p>Where I added the 4 cols to my model</p>
  
  <pre><code>rails g migration AddEncryptedColumnsToUser encrypted_email:string encrypted_password:string encrypted_email_iv:string encrypted_password_iv:string 
  </code></pre>
  
  <p>Now I want to check if email and password are correct, but I don't know how to process:</p>
  
  <pre><code>secret_key_data = "my big secret 32 bits key "
  email = User.encrypt_email("test@test.com", key: secret_key_data)
  password = User.encrypt_password("test", key: secret_key_data)
  User.where('(encrypted_email) LIKE ? AND (encrypted_password) LIKE ? ', email,password)
  </code></pre>
  
  <p>but when I do:</p>
  
  <pre><code>email = User.encrypt_email("test@test.com", key: secret_key_data)
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>ArgumentError: must specify an iv
  </code></pre>
  
  <p>Question is, <strong>where do I get the iv from, and how do I encrypt to be able to test in the db if the login is right?</strong></p>
  
  <p>Thanks a lot!</p>