README.md in ahoy_email-1.0.1 vs README.md in ahoy_email-1.0.2

- old
+ new

@@ -36,11 +36,11 @@ ### Message History Ahoy creates an `Ahoy::Message` record for each email sent by default. You can disable history for a mailer: ```ruby -class UserMailer < ApplicationMailer +class CouponMailer < ApplicationMailer track message: false # use only/except to limit actions end ``` Or by default: @@ -56,11 +56,11 @@ By default, Ahoy tries `@user` then `params[:user]` then `User.find_by(email: message.to.first)` to find the user. You can pass a specific user with: ```ruby -class UserMailer < ApplicationMailer +class CouponMailer < ApplicationMailer track user: -> { params[:some_user] } end ``` The user association is [polymorphic](https://railscasts.com/episodes/154-polymorphic-association), so use it with any model. @@ -166,11 +166,11 @@ ``` And add to mailers you want to track: ```ruby -class UserMailer < ApplicationMailer +class CouponMailer < ApplicationMailer track open: true, click: true # use only/except to limit actions end ``` #### How It Works @@ -260,9 +260,26 @@ Or fully customize how messages are tracked ```ruby AhoyEmail.track_method = lambda do |data| # your code +end +``` + +## Mongoid + +If you prefer to use Mongoid instead of ActiveRecord, create `app/models/ahoy/message.rb` with: + +```ruby +class Ahoy::Message + include Mongoid::Document + + belongs_to :user, polymorphic: true, optional: true, index: true + + field :to, type: String + field :mailer, type: String + field :subject, type: String + field :sent_at, type: Time end ``` ## Upgrading