ユーザーモデルのメールフィールドはattr_encryptedで暗号化されています。 deviseとfacebook omniauthで新しいユーザーを作成すると、実際にDBに保存されます。また、そのデータをUser.last.email #=> [email protected]
で取得できます。'find_by'と 'where'はattr_encryptedと連携していません
User.find_by_email("[email protected]")
またはUser.where(email: "[email protected]")
を使用すると、nilまたは[]が返されます。
user.rb
class User < ActiveRecord::Base
attr_encrypted :email, key: Settings.encryption.key
end