Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3652

geo_near as Scope

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0
    • Affects Version/s: None
    • Component/s: None

      Hi I am using 4.0.0.beta1 and I cannot use geo_near as a scope:

      class Moment
        include Mongoid::Document
      
        field :location, type: Array
      
        index({ location: "2dsphere" }, background: true)
      
        scope :near_by, lambda {|location, distance| geo_near(location).spherical.distance_multiplier(6371.39).max_distance(distance / 6371.39)}
      end
      
      Moment.near_by([ 51.545099, -0.0106 ], 1.083).each {|a| p a}
      NoMethodError: undefined method `to_criteria' for #<Mongoid::Contextual::GeoNear:0x007f84a71cb550>
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            JakubRacek JakubRacek [X]
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: