Check out the Geocoder gem. It supports ActiveRecord and several DB engines, including PostgreSQL.
If you have a Venue
model, you can add geocoding to it and do things like:
nearby_places = Venue.near([lat, long], distance)
There is also an example on advanced queries at GitHub for this project, quoted in full below.
When querying for objects (if you're using ActiveRecord) you can also look within a square rather than a radius (circle) by using the within_bounding_box scope:
distance = 20
center_point = [40.71, 100.23]
box = Geocoder::Calculations.bounding_box(center_point, distance)
Venue.within_bounding_box(box)
This can also dramatically improve query performance, especially when used in conjunction with indexes on the latitude/longitude columns. Note, however, that returned results do not include distance and bearing attributes. If you want to improve performance AND have access to distance and bearing info, use both scopes:
Venue.near(center_point, distance).within_bounding_box(box)