I want to return a list of job postings that are near a location (based on [latitude, longitude]). I am using geocoder and it seems to be working. I can import a CSV file with a list of addresses and geocoder populates the latitude and the longitude columns.
But I can't seem to get the near or nearby functions to work. It returns a undefined method error. I've tried following this: Rails Geocoder - Still learning which explains that nearby is a model function. But the example there did not work for me either.
This is what I have in my show.html.erb:
<%= @jobposting.latitude %>, <%= @jobposting.longitude %>
40.7494011, -73.9389437
<% @location = Jobposting.near([@jobposting.latitude, @jobposting.longitude], 150) %>
<%= @location.inspect %>
It does not error but returns a empty array: #<ActiveRecord::Relation []> when there are points within 10 miles of the latitude and longitude.
I'm unsure if I am calling it incorrectly, based on the documentation it looks like near is used with the model but not limited to calling it in the model.