module ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting

def unescape_bytea(value)

on escaped binary output from database drive.
NOTE: This is NOT an inverse of escape_bytea! This is only to be used
Unescapes bytea output from a database to the binary string it represents.
def unescape_bytea(value)
  @connection.unescape_bytea(value) if value
end