title: Escaping apostrophe in Ruby
body: <p>I am trying to escape a single quote in a ruby string. I am using this string as a insert query to push data into the postgresql.</p>
  
  <p>The query that will be generated looks something like this:-</p>
  
  <pre><code>str = insert into table field1,field2 values 'Gaurav's', 'Scooter'
  </code></pre>
  
  <p>I tried escaping it with </p>
  
  <pre><code>str.gsub("/'/",\\\\')
  </code></pre>
  
  <p>But this didn't work.</p>
  
  <p>The error that I always get is:
  <strong>Syntax Error Near s:</strong></p>
  
  <p>I guess i would need a regex to escape single quote inside the two single quotes not sure though.</p>
  
  <p>How do I fix this? Thank you.</p>