I am writing an application that should quickly process hundreds of thousands of rows of data, so I searched for the embedded raw SQL code in my Ruby code with help ActiveRecord::Base.connection.executethat works great. However, whenever I run it, I get the following object:
#<PG::Result:0x007fe158ab18c8 status=PGRES_TUPLES_OK ntuples=0 nfields=1 cmd_tuples=0>
I searched googled and can't find a way to parse the PG result into something really useful. Is there a built-in PG method for this or a workaround or something really?
Here is the query I'm using:
SELECT row_to_json(row(company_name, ccn_short_title, title))
FROM contents
WHERE contents.company_name = '#{company_name}'
AND contents.title = '#{title}';
source
share