title: Rails where not equals *any* of array of values
body: <p>I've tried to do stuff like this</p>
  
  <pre><code>not_allowed = ['5', '6', '7']
  sql = not_allowed.map{|n| "col != '#{n}'"}.join(" OR ")
  Model.where(sql)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>not_allowed = ['5', '6', '7']
  sql = not_allowed.map{|n| "col &lt;&gt; '#{n}'"}.join(" OR ")
  Model.where(sql)
  </code></pre>
  
  <p>but both of these just return my entire table which isn't accurate.</p>
  
  <p>So I've done this and it works:</p>
  
  <pre><code>shame = values.map{|v| "where.not(:col =&gt; '#{v}')"  }.join(".")
  eval("Model.#{shame}")
  </code></pre>
  
  <p>and I'm not even doing this for an actual web application, I'm just using rails for its model stuff. So there aren't any actual security concerns for me. But this is an awful fix and I felt obligated to post this question</p>