title: Is there a way to invert an ActiveRecord::Relation query?
body: <p>Let's say we have the following:</p>
  
  <pre><code>irb&gt; Post.where(:hidden =&gt; true).to_sql
  =&gt; "SELECT `posts`.* FROM `posts` WHERE posts.hidden = 1"
  </code></pre>
  
  <p><strong>Could we somehow get an inverted SQL query out of it?</strong></p>
  
  <p>What I am looking for, should probably look like this:</p>
  
  <pre><code>irb&gt; Post.where(:hidden =&gt; true).invert.to_sql
  =&gt; "SELECT `posts`.* FROM `posts` WHERE NOT (posts.hidden = 1)"
  </code></pre>