1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25class Subscription < ApplicationRecord # Soft delete scope :active, -> { where(deleted_at: nil) } # Relationships belongs_to :customer belongs_to :category # Validations validates :customer_id, uniqueness: { scope: :category_id } # Instance methods def soft_delete update(deleted_at: Time.current) end def restore update(deleted_at: nil) end def deleted? deleted_at.present? end end