ryanong/mongoid_spacial — Issue #13: Cannot chain geo_near
Author: pdelanauze
Created: 2011-12-01 04:33:05+00:00
State: open

Can we not chain the geo_near query ?

Say we have a scope

```ruby
scope :enabled, where(:enabled => true)
```

This chain would work:
```ruby
def look_for_enabled_close_to
self.enabled.geo_near([1.0, 1.0], :max_distance => 5, :unit => :km, :spherical => true)
end
```

This would not, throws a NoMethodError: undefined method `scoped' for #

```ruby
def look_for_enabled_close_to
self.geo_near([1.0, 1.0], :max_distance => 5, :unit => :km, :spherical => true).enabled
end
```

Also, wrapping geo_near in a scope results in the same exception being thrown...
e.g.
```ruby
scope :geo_near_plus_plus, lambda {|coords, rad| geo_near(coords, :max_distance => rad)}
```