Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
Created July 7, 2011 21:49
Show Gist options
  • Save JakubOboza/1070631 to your computer and use it in GitHub Desktop.
Save JakubOboza/1070631 to your computer and use it in GitHub Desktop.
# define class
class Location
include Mongoid::Document
# fields
field :location, :type => Array
index [[ :location, Mongo::GEO2D ]], :min => -180, :max => 180
field :name
# validations
validates_presence_of :name
end
# How to query ?
@loc = Location.near(:location => [ 1.0, 1.0, 1.0 ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment