I\'m trying to write a validation where only one record can be true.
I have a \'game\' model with an \'active\' boolean column, only one game can be active at any time, so if so
Try using the exists? method. Also, add the error using the add method.
validate :active_game
scope :active, where(active: true)
def active_game
if active && Game.active.where("id != ?", id).exists?
errors.add(:name, "a game is already active!")
end
end