title: Rails custom validation - Only one record can be true
body: <p>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 someone tries to create a new 'game' record when there is an already active game then they should get an error. Below is what I currently have but isn't working!</p>
  
  <pre><code>validate :active_game
  
    def active_game
      if active == true &amp;&amp; Game.find_by(active: true) == true
         errors[:name] = "a game is already active!"
      end
    end
  </code></pre>