Getting started
Installation
Add the gem to your Rails application:
bash
bundle add missiveInstall the migrations, then run them:
bash
bin/rails generate missive:install
bin/rails db:migrateThe installer creates a single migration with the missive_* tables.
Configuration
Postmark API credentials
Missive uses the same configuration as postmark-rails. Follow the postmark-rails configuration instructions to set up your Postmark API credentials.
Mount the engine
Missive ships a Rails engine that receives Postmark webhooks. Mount it in config/routes.rb:
rb
Rails.application.routes.draw do
mount Missive::Engine => "/missive"
endThe webhook endpoint is then available at POST /missive/postmark/webhooks. See Postmark webhooks to connect it to Postmark.
Webhook secret
Incoming webhooks are authenticated with a shared secret, read from your Rails credentials:
bash
bin/rails credentials:edityaml
postmark:
webhooks_secret: a-long-random-stringSee Credentials for details.
Quick start
Connect your User model:
rb
class User < ApplicationRecord
include Missive::User
endCreate a sender and a list, then subscribe a user to it:
rb
admin = User.find_by(email: "editor@example.com")
sender = admin.init_sender(name: "The Editor")
list = Missive::List.create!(name: "My newsletter", sender:)
user = User.first
user.init_subscriber
user.missive_subscriber.subscriptions.create!(list:)Next steps
- Connecting your User model, including how to rename the associations
- Subscribers & subscriptions
- Senders & lists
- Postmark webhooks