From bfdef8dc68265d772ddbf514c09ecfa2c6eee92c Mon Sep 17 00:00:00 2001 From: John McKerrell Date: Sat, 5 May 2007 13:37:13 +0000 Subject: [PATCH] Made nearest method work with nil home lat/lon. --- app/models/user.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index ce12755df..887dcb388 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -61,7 +61,11 @@ class User < ActiveRecord::Base def nearby(lat_range=1, lon_range=1) - nearby = User.find(:all, :conditions => "#{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and #{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and data_public = 1") + if self.home_lon and self.home_lat + nearby = User.find(:all, :conditions => "#{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and #{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and data_public = 1") + else + nearby = [] + end return nearby end -- 2.39.5