I’m looking at ways to encrypt email addresses rather than storing
them directly in the database.
There are several ways that it could be done. I could make an
Encrypter class and use before_update, etc. Or I could set up an
updatable VIEW in mySql. (I guess triggers might be another
However, what I would really LIKE to do is use the handy AES_ENCRYPT
and AES_DECRYPT functions in mySql. If I were doing this with
straight sql, I would just use
INSERT INTO myTable VALUES( null, ‘user name’, AES_ENCRYPT
(‘user_email’ , ‘password’ ).
Since ActiveRecord handles all this for me, it is not clear if I can
override the insert, update and select statements for a table. It
may not be a very good idea, but I’d like more information before
giving up on it.