geo_near as Scope

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • 5.1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
              Reporter:
              JakubRacek [X]
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: