Message WIP
An email sent to the subscribers of a given list.
Work in progress
Message content and sending are not implemented yet. See Sending messages.
Columns
| Column | Type | Notes |
|---|---|---|
subject | string | required |
list_id | bigint | required |
sender_id | bigint | required |
postmark_message_stream_id | string | |
dispatches_count | integer | counter cache, default 0 |
sent_at | timestamp | backs the sent boolean |
Associations
belongs_to :list, counter_cache: :messages_count→ Listbelongs_to :sender→ Senderhas_many :dispatches, dependent: :destroy→ Dispatch
Validations
subjectpresence
Timestamp booleans
sent is backed by sent_at through time_for_a_boolean:
| Method | Effect |
|---|---|
sent? / sent | true when sent_at is set and in the past |
sent! | sets sent_at to the current time (doesn't save) |
sent = false | clears sent_at |