Reputation: 5905
I have a model named Offering and User
user has_many offerings.
Every offering has two fields long
, lat
which contains the longitude latitude of the offering, where it is created.
Suppose, A user's location is 2.323, -32.344. Now I want to show him the offerings which is within 10 miles radius from his location.
I'm using MySQL, engine= INNODB
Have any idea?
Upvotes: 0
Views: 73
Reputation: 115521
Geocoder does provide such kind of scopes:
# venues within 10 miles of 'Omaha, NE, US'
Offering.near('Omaha, NE, US', 10)
# venues within 10 miles of [40.71, 100.23]
Offering.near([40.71, 100.23], 10)
Upvotes: 1