If you have the longitude and latitude of the user's location, you can make such a request
location_info = request.location @locations = Location.near([location_info.latitude, location_info.longitude], radius_distance_you_want_to_include)
It was also expected that your table, i.e. in the above Location example, must be lat and lon .
Is this what you were looking for?
EDIT: I'm not sure if request.location will work in the model. Otherwise, you can always set it as a parameter to a model method inside your controller so that your logic remains divided. But if possible, save request.location in the model.
source share