class Subscription < ApplicationRecord
  has_many :newsletter_delivers
  has_many :newsletters, through: :newsletter_delivers
  scope :weekly, -> { where(created_at: Time.current.beginning_of_week..) }
  scope :monthly, -> { where(created_at: Time.current.beginning_of_month..) }

  validates :email, presence: true, uniqueness: true
end
