alexreisner/geocoder — pull request #236 by dubroe (2012-05-17 04:41:32+00:00)
Title: Put in full_column_name to avoid ambiguous column errors

Small change but is required if you want to have a self join on a geocoded table that you called "nearbys" on. For example, in Class Address which is geocoded:

nearby_addresses = nearbys(NEARBY_DISTANCE, bearing: false).joins("LEFT JOIN addresses t2 on addresses.vendor_id=t2.vendor_id AND ...)

The original code caused the ambiguous column errors on latitude and longitude because of the self join.

If you're curious, I'm doing this because I want to get addresses ordered by distance but unique for a particular column. I'm using the technique in this article: http://www.williambharding.com/blog/uncategorized/mysql-use-distinct-and-order-by-with-multiple-columns-aka-apply-order-by-before-group/