alexreisner/geocoder — pull request #473 by eabraham (2013-06-23 18:51:38+00:00)
Title: Return ActiveRecord::Relation instead of nil for nearbys

When an ActiveRecord::Base fails to be geocoded and the method nearbys is called, the returned value is nil. Often this nil would break logic when chained with additional scopes and I would need to write extra code to check for nil. By returning an empty ActiveRecord::Relation this removes the need for that extra check.

I've taken your feedback into account and I'll address each of your concerns

* Need to support MongoDB too (current implementation will cause an error).
* Now works with MongoDB
* 1==0 is not valid SQL.
* Using a where(1==0) is a standard practice to create a null relation in rails 3.
* Better not to add a scope in the model space (might overwrite user scope).
* I've dropped the :none scope and replaced it with a class method
* nearbys is the only one of those methods that returns an ActiveRecord::Relation. The others should return nil.
* I've limited the scope of this change to the nearbys method

Reference previous pull request:
https://github.com/alexreisner/geocoder/pull/471