title: escaping query for SQL LIKE in rails
body: <p>In rails source (<a href="https://github.com/rails/rails/blob/fe4b0eee05f59831e1468ed50f55fbad0ce11e1d/activerecord/lib/active_record/sanitization.rb#L112" rel="noreferrer">https://github.com/rails/rails/blob/fe4b0eee05f59831e1468ed50f55fbad0ce11e1d/activerecord/lib/active_record/sanitization.rb#L112</a>) there is a <code>sanitize_sql_like</code> method that (I am hoping) will sanitize strings before using them with a SQL LIKE</p>
  
  <p>however, I can't seem to use that, as Rails says that method doesn't exist. </p>
  
  <p>My string has an apostrophe in it and the query is </p>
  
  <pre><code>@query = "Joe's"
  Model.where("lower(field) LIKE ?", "%#{@query}%") 
  </code></pre>
  
  <p>Using <code>ActiveRecord::Base.sanitize</code> doesn't help, as there are no results for the query. </p>
  
  <p>How can I escape <code>@query</code>, and keep my SQL secured?</p>