Schwad said over 7 years ago on attr_encrypted :

I *really* enjoyed this screencast, and can't wait to try out this gem on my next app! Keep up the good work and thanks again!

volker said over 7 years ago on attr_encrypted :

Hi there,

thanks a lot for the great series, especially for this episode, which lead me to trying out this gem.

With my tests, I am running into problems. I am trying out to encrypt the safeword of my user model.

class User < ApplicationRecord
attr_encrypted :safeword,
                 key: Rails.application.secrets.attr_encrypted_key,
                 encode: true,
                 encode_iv: true,
                 encode_salt: true

The new standard of attr_encrypted needs an iv_column for the encrypted field. So my fixtures like:

  name: SterlingArcher
  password_digest: <%= User.digest('password') %>
  safeword: safeword

fail with a "table "user" has no column named "safeword"" error.

I would like to replace "safeword" with

encrypted_safeword: <%= User.encrypt_safeword('safeword', key: Rails.application.secrets.attr_encrypted_key)

But how to I set the required "encrypted_safeword_iv" field? How do I calculate the iv value?

Any help is very appreciated!

Thanks a lot!



chabgood said about 6 years ago on attr_encrypted :
I have a rails 5 app that is an API, I am getting this error: It was working fine before I added the gem. ActiveRecord::StatementInvalid (Mysql2::Error: Unknown column '' in 'where clause': SELECT `disclosure_forms`.* FROM `disclosure_forms` WHERE `disclosure_forms`.`name` = 'Chris Habgood' LIMIT 1):

Login to Comment