aalpern/parse-ruby-client — Issue #3: Invalid type for key location, expected geopoint
Author: allaire
Created: 2012-02-23 14:42:44+00:00
State: open

I'm trying to use the Gem's GeoType datatype like this:

def save
if (!valid?)
return false
else
parking = Parse::Object.new("Parking")

data =
{
"longitude" => 40.0,
"latitude" => -30.0
}

point = Parse::GeoPoint.new(data)

parking["name"] = name
parking["address"] = address
parking["city"] = city
parking["location"] = point
parking["contributorName"] = contributor_name
parking["contributorEmail"] = contributor_email

if (parking.save)
return true
end
end
end

and it returns me : " Invalid type for key location, expected geopoint"

I had to use:

parking["location"] = {"__type" => "GeoPoint", "latitude" => latitude.to_f, "longitude" => longitude.to_f}

in order to make this work.

Is this normal? What's the purpose of the GeoPoint class in the gem if we have submit an hash? At first I thought it was for fetching data only, but I still access the longitude/latitude using <%= parking["location"]["longitude"] %> ...

Thank you !