I’m currently using the GeoKit plugin for a Rails web application I’m
building, and I’m having a problem with the “find all locations within
a distance from this location” aspect of it.
I have a browse form, which takes a distance, and a zipcode, and
returns all locations that fit. However, it seems to only be returning
the first location for each zipcode it finds.
For example, I have 5 locations:
Loc1 - 02110
Loc2 - 02110
Loc3 - 02360
Loc4 - 02110
Loc5 - 02360
The search function only returns two results, Loc1 and Loc3. My search
function in the controller looks like this:
def search
if params[:zip]
@location = Location.find(:all, :origin =>
params[:zip], :within => params[:miles]
@location = @location.sort_by { |location| location.name }