it sounds like not difficult at all but after looking for a while I can't find a way to change the limit
of the closest
scope in Geokit-rails
.
I've tried to overide the definition of this method which is defined according to the documentation as:
def closest(options = {})
geo_scope(options).order("#{distance_column_name} asc").limit(1)
end
but with no success.
Any idea? Thank you very much!
That's an older version of geokit-rails/geokit, now the definition is:
def closest(options = {})
by_distance(options).first(1)
end
So no need to override anything, your code could simply say:
MyClass.by_distance(options).limit(my_limit)
Note: Try to avoiding monkey patching existing code. If you did what was suggested in another comment it might work now, but as soon as you update geokit/geokit-rails you risk it breaking as implementations do change (e.g. the closest method is implemented rather differently.