title: Coping with "string contains null byte" sent from users
body: <p>I have an API controller that receives information about a media file's path and id3 tags, and saves them to an Active Record instance, using PostgreSQL/Rails.</p>
  
  <p>Sometimes however the user sends strings such as:</p>
  
  <pre><code>"genre"=&gt;"Hip-Hop\u0000Hip-Hop/Rap"
  </code></pre>
  
  <p>and Rails/Postgres aren't exactly happy about that when trying to persist on <code>save</code>:</p>
  
  <pre><code>An ArgumentError occurred in internals#receive:
  
   string contains null byte
   activerecord (3.2.21) lib/active_record/connection_adapters/postgresql_adapter.rb:1172:in `send_query_prepared'
  </code></pre>
  
  <p>How can I clean this string in Ruby to completely remove null bytes?</p>