diff --git a/app/models/thing.rb b/app/models/thing.rb index 543c0f2..bf1b227 100644 --- a/app/models/thing.rb +++ b/app/models/thing.rb @@ -7,7 +7,7 @@ class Thing < ActiveRecord::Base def self.find_closest(lat, lng, limit=10) query = <<-SQL - SELECT *, (3959 * ACOS(COS(RADIANS(?)) * COS(RADIANS(lat)) * COS(radians(lng) - RADIANS(?)) + SIN(RADIANS(?)) * SIN(RADIANS(lat)))) AS distance + SELECT *, (3959 * ACOS(COS(RADIANS(?)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(?)) + SIN(RADIANS(?)) * SIN(RADIANS(lat)))) AS distance FROM things ORDER BY distance LIMIT ?