Sha256: b5c310b56c0183de0a169bed2d9bf15d92f8d0e7361757b3418a052ad6427577
Contents?: true
Size: 457 Bytes
Versions: 15
Compression:
Stored size: 457 Bytes
Contents
class ChatUser < AbstractAdapter belongs_to :chat belongs_to :user alias_attribute :joined_at, :created_at alias_attribute :left_at, :departed_at scope :current, ->{ where(departed_at: nil) } validate :user_not_already_active, on: :create def user_not_already_active errors[:base] << "#{user.name} is already present in this chat." if chat.chat_users.where(user_id: user.id, departed_at: nil).count > 0 && user.persisted? end end
Version data entries
15 entries across 15 versions & 1 rubygems