I am using the PostGIS ActiveRecord Adapter in a Rails API app. I have a DB table called events where one of the columns is a PostGIS geometry column called coordinates e.g.:
create_table 'events' do |t|
t.geometry 'coordinates;
end
When a user queries my API, I use Netflix's Fast JSON API to serialize my response:
class EventSerializer
include FastJsonapi::ObjectSerializer
attribute :coordinates do |object|
# coincidentally my column name and PostGIS Adapters method for getting the coordinates is the same
object.coordinates.coordinates
end
end
Now most of the time the above works and I get a response that has the coordinates, but every now and then I will get the following error:
'undefined method coordinates for "0101000020E610000061C3D32B65965DC03657CD7344F64040" String, did you mean codepoints'
The above happens sporadically and I cannot recreate it since most of the time everything works fine. And by fine I mean I only have 5 records in the database and if execute the same function that ultimately serializers the 5 records, it will work 50 times but then 1 time it will give me the error above and keep giving me the error above in subsequent calls. I then restart the server and all goes back to normal.
My best guess is that the serializer is processing the object faster than the adapter is parsing the RGeo object to return the coordinates, but I am not sure how to fix that.
Anyone have any solutions?