title: How to use `matches()` with a database function?
body: <p>I had an ActiveRecord scope like this:</p>
  
  <pre><code>scope :matching, -&gt;(query) {
    where Post.arel_table[:title].matches "%#{query}%"
  }
  </code></pre>
  
  <p>This worked fine.  I then changed it to ignore extra whitespace in the <code>title</code>:</p>
  
  <pre><code>scope :matching, -&gt;(query) {
    where "regexp_replace(title, '\\s+', ' ', 'g') ILIKE ?", "%#{query}%"
  }
  </code></pre>
  
  <p>This works but I have had to drop down from <code>matches()</code> (at the Ruby level) to <code>ILIKE</code> (at the SQL level).</p>
  
  <p>Is it possible to use <code>regexp_replace(...)</code> with <code>matches()</code>?  For example:</p>
  
  <pre><code>scope :matching, -&gt;(query) {
    where handwaving("regexp_replace(title, '\\s+', ' ', 'g')").matches "%#{query}%"
  }
  </code></pre>
  
  <p>(I tried to use an <code>Arel::Nodes::NamedFunction</code> but couldn't get it to work.)</p>