ruby-on-railspostgresqlgoogle-geocoderrails-geocodergeocoder

Geocoder - How to use near query with multiple points?


I have one model Store, Every store has its radious limit for delivery.

For an example,

Store 1 can delivery within 10 miles

Store 2 can delivery within 30 miles

So i have diffrent points for every store, In past i was used below query to find out store withing a specific range

@stores = Store.near([latitude, longitude], 100, :order => false)

I don't have specific range now, How can i do query for multiple points of stores ? Any help or suggestion will be appreciated to overcome this issue .


Solution

  • Found the solution i need to pass database column name to get correct result with below query

    Store.near([latitude, longitude], :delivery_within)
    

    delivery_within is database column which is in stores table.