-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I've create following custom type
class LatLng include Mongoid::Fields::Serializable def deserialize(object) { :lat => object[1], :lng => object[0] }.with_indifferent_access end def serialize(object) latlng = object.with_indifferent_access [ latlng[:lng], latlng[:lat] ] end end
Running of this query
field :from_latlng, type: LatLng
doc.where(:from_latlng =>
{"$nearSphere" => [lng, lat], "$maxDistance" => radius / EARTH_RADIUS}) will cause exception due to it tries to serialize params from complex criteria hash using my custom type.