|
- 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?
- def banned = banned?
-
- def banned= value
- bool = ActiveModel::Type::Boolean.new.cast(value)
- self.banned_at = bool ? banned_at || Time.current : nil
- end
- end
|