Postgres long running query not blocking table operations
Ruby will close the cursor when it is done iterating over it.  If you already know that that will take a long time, then there is no reason to think it isn't working correctly.  Can you set log_statement ='all' to see when the CLOSE and COMMIT arrive if you want to double check.

Using single row mode won't change the situation.  It will still hold locks until it is done.  It will just change the chunk size fetched from the server from 1000 (or whatever the cursor uses) to 1.

I know that the dblink function does spool its results to disk, so that it can release locks (on the remote end) as quickly as possible. It is the only thing I know of that does that on the server side. Perhaps you can use dblink to loop back to the same database server and run the query through it, then use single row mode to get the results, although I don't know how you get Ruby to make use of single-row-mode.  I've only seen it done from C.  You can probably get Ruby to use a cursor with a dblink query.