class IpAddress < ApplicationRecord validates :ip_address, presence: true, length: { maximum: 16 } has_many :user_ips, dependent: :destroy has_many :users, through: :user_ips def banned? = banned_at.present? def ban! = update!(banned_at: Time.current) end