README.md in ahoy_email-1.0.3 vs README.md in ahoy_email-1.1.0

- old
+ new

@@ -51,11 +51,11 @@ ### Users Ahoy records the user a message is sent to - not just the email address. This gives you a full history of messages for each user, even if he or she changes addresses. -By default, Ahoy tries `@user` then `params[:user]` then `User.find_by(email: message.to.first)` to find the user. +By default, Ahoy tries `@user` then `params[:user]` then `User.find_by(email: message.to)` to find the user. You can pass a specific user with: ```ruby class CouponMailer < ApplicationMailer @@ -241,10 +241,26 @@ end AhoyEmail.subscribers << EmailSubscriber.new ``` +## Data Protection + +Protect the privacy of your users by encrypting the `to` field. [attr_encrypted](https://github.com/attr-encrypted/attr_encrypted) is great for this. Use [blind_index](https://github.com/ankane/blind_index) if you need to query by the `to` field. + +Create `app/models/ahoy/message.rb` with: + +```ruby +class Ahoy::Message < ApplicationRecord + self.table_name = "ahoy_messages" + belongs_to :user, polymorphic: true, optional: true + + attr_encrypted :to, key: ... + blind_index :to, key: ... +end +``` + ## Reference Set global options ```ruby @@ -301,13 +317,13 @@ - Only sent emails are recorded - Proc options are now executed in the context of the mailer and take no arguments ```ruby # old - user: ->(mailer, message) { User.find_by(email: message.to.first) } + user: ->(mailer, message) { User.find_by(email: message.to) } # new - user: -> { User.find_by(email: message.to.first) } + user: -> { User.find_by(email: message.to) } ``` - Invalid options now throw an `ArgumentError` - `AhoyEmail.track` was removed in favor of `AhoyEmail.default_options` - The `heuristic_parse` option was removed and is now the default