Sha256: 423aa18ec3e50ee489b9bff50f72daa9c4ec0f9a039db51aa525f0d04827ee6c
Contents?: true
Size: 458 Bytes
Versions: 13
Compression:
Stored size: 458 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
13 entries across 13 versions & 1 rubygems