Sha256: a114f760f67d669449c4ea012058a52b46c38b006fbf7e2ef08149050ef146f1
Contents?: true
Size: 633 Bytes
Versions: 4
Compression:
Stored size: 633 Bytes
Contents
# frozen_string_literal: true module Decidim # This model holds all the data needed to send a newsletter. class Newsletter < ApplicationRecord belongs_to :author, class_name: User belongs_to :organization validates :subject, :body, presence: true validate :author_belongs_to_organization # Returns true if this newsletter was already sent. # # Returns a Boolean. def sent? sent_at.present? end private def author_belongs_to_organization return if !author || !organization errors.add(:author, :invalid) unless author.organization == organization end end end
Version data entries
4 entries across 4 versions & 1 rubygems