1

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.

Mark Locklear
  • 5,044
  • 1
  • 51
  • 81

1 Answers1

1

They have some new scopes so you could do:

SapApplication.within 10, origin: '100 Spear st, San Francisco, CA'
smathy
  • 26,283
  • 5
  • 48
  • 68
  • 1
    Thanks! The first suggestion using a where clause does not work. I get the error `PG::UndefinedColumn: ERROR: column sap_applications.origin does not exist`, but the 2nd suggestion just using .within does work. – Mark Locklear Mar 01 '19 at 14:53
  • 1
    Thanks for the feedback, I've updated my answer so it could help others. – smathy Mar 01 '19 at 17:29