ruby-on-railsgeokit

ArgumentError: Unknown key: origin using geokit-rails


I have a rails 4 app where I am trying to find all applications within N number of miles. Based on geokit-rails documention HERE I should be able to do:

SapApplication.find(:all, :origin=>'100 Spear st, San Francisco, CA', :within=>10)

When I try and execute the command above in the console I get the error:

ArgumentError: Unknown key: origin

The SapApplication model has acts_as_mappable and attributes for lat/lng.

Just as an aside SapApplication.by_distance(:origin => [37.792,-122.393]) does work, so I at least know geokit is installed correctly.


Solution

  • They have some new scopes so you could do:

    SapApplication.within 10, origin: '100 Spear st, San Francisco, CA'