-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
Can we not chain the geo_near query ?
Say we have a scope
scope :enabled, where(:enabled => true)This chain would work:
def look_for_enabled_close_to
self.enabled.geo_near([1.0, 1.0], :max_distance => 5, :unit => :km, :spherical => true)
endThis would not, throws a NoMethodError: undefined method `scoped' for #Mongoid::Spacial::GeoNearResults:0x00000105455258
def look_for_enabled_close_to
self.geo_near([1.0, 1.0], :max_distance => 5, :unit => :km, :spherical => true).enabled
endAlso, wrapping geo_near in a scope results in the same exception being thrown...
e.g.
scope :geo_near_plus_plus, lambda {|coords, rad| geo_near(coords, :max_distance => rad)}Here's the stack trace
NoMethodError: undefined method `scoped' for #<Mongoid::Spacial::GeoNearResults:0x00000105455258>
from /Users/pat/.rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.3.4/lib/mongoid/extensions/proc/scoping.rb:20:in `scoped'
from (eval):3:in `geo_near_plus_plus'
from /Users/pat/.rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.3.4/lib/mongoid/criteria.rb:379:in `block in method_missing'
from /Users/pat/.rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.3.4/lib/mongoid/named_scope.rb:120:in `with_scope'
from /Users/pat/.rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.3.4/lib/mongoid/criteria.rb:378:in `method_missing'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels