I have a Postgres database with PostGIS extension and some geo-data in it. I need to generate tiles with custom SQL queries (using ST_... functions), that returns binary data (bytea, like \x1a320a0474657374121d12020000180322150946ec3f1a14453b0a09280f091413121e09091e0f1a026331220228012880207802). And I need to send this data from my Rails controller to the requester, with the headers like 'Content-Type: x-application/protobuf'.
So, my question is:
1) How to get the binary data from the Database (Sequel, ActiveRecord::Base.connection.execute ?)
2) How to return this data in the controller action? (send_data ..., tyle: '' ?)
Thanks!
I just figured out the solution - hope it helps, although it's a long time ago..
ActiveRecord::Base.connection.unescape_byteais the answer.