retrospring/app/models/user_ban.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
303 B
Ruby
Raw Normal View History

class UserBan < ApplicationRecord
belongs_to :user
2022-06-26 11:01:39 +02:00
belongs_to :banned_by, class_name: "User", optional: true
2021-08-14 18:04:58 +02:00
2022-06-26 11:01:39 +02:00
scope :current, -> { where("expires_at IS NULL or expires_at > NOW()") }
def permanent?
expires_at.nil?
end
2022-07-02 12:53:14 +02:00
def current?
permanent? || expires_at > Time.now.utc
end
end