近返回没有结果

时间:2013-02-01 20:32:38

标签: ruby-on-rails gmaps4rails

我最近将新数据导入到我的应用中,现在附近没有返回任何结果。这是模型中的最新内容:

attr_accessible :address, :church_id, :oldid, :email, :facilities, :lat, :long, :phone, :service_times, :title, :zipcode, :latitude, :longitude, :city, :photo, :gmaps, :pastors_attributes

has_many :pastors
belongs_to :church

accepts_nested_attributes_for  :pastors

geocoded_by :gmaps4rails_address, :latitude  => :lat, :longitude => :long

acts_as_gmappable

def gmaps4rails_address
  "#{self.address}, #{self.city}, #{self.zipcode}, USA" 
end

以下是我的控制器中的内容

@json = Location.near(params[:search], 50, :order => :distance).to_gmaps4rails

我甚至尝试在控制台中运行它而没有运气。以下是控制台会话的示例:

ruby-1.9.2-p290 :003 > Location.near("Lynchburg VA USA", 50)
  Location Load (1.9ms)  SELECT locations.*, (69.09332411348201 * ABS(locations.lat - 37.4137536) * 0.7071067811865475) + (59.836573914187355 * ABS(locations.long - -79.14224639999999) * 0.7071067811865475) AS distance, CASE WHEN (locations.lat >= 37.4137536 AND locations.long >= -79.14224639999999) THEN 45.0 WHEN (locations.lat < 37.4137536 AND locations.long >= -79.14224639999999) THEN 135.0 WHEN (locations.lat < 37.4137536 AND locations.long < -79.14224639999999) THEN 225.0 WHEN (locations.lat >= 37.4137536 AND locations.long < -79.14224639999999) THEN 315.0 END AS bearing FROM "locations" WHERE (locations.lat BETWEEN 36.69009468444576 AND 38.13741251555424 AND locations.long BETWEEN -80.05334717064996 AND -78.23114562935002) ORDER BY distance
 => []

我可以查看位置并看到它们已经被正确地编码,我甚至可以查看它们的长值和纬度值,看它们是否正确。我很难过为什么这个新数据突然不起作用,当它基本上是旧数据的清理版本时。

我在控制台内创建了一个新位置,以确保Google没有限制我的连接,它似乎没有问题:

ruby-1.9.2-p290 :005 > a = testchurch.locations.build(:address => "401 Suburban Road", :city => "Lynchburg", :zipcode => "24501")
 => #<Location id: nil, title: nil, address: "401 Suburban Road", zipcode: "24501", phone: nil, email: nil, lat: nil, long: nil, service_times: nil, facilities: nil, church_id: nil, created_at: nil, updated_at: nil, latitude: nil, longitude: nil, gmaps: nil, city: "Lynchburg", photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, oldid: nil> 
ruby-1.9.2-p290 :006 > a.save
   (0.1ms)  begin transaction
  SQL (0.6ms)  INSERT INTO "locations" ("address", "church_id", "city", "created_at", "email", "facilities", "gmaps", "lat", "latitude", "long", "longitude", "oldid", "phone", "photo_content_type", "photo_file_name", "photo_file_size", "photo_updated_at", "service_times", "title", "updated_at", "zipcode") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)  [["address", "401 Suburban Road"], ["church_id", nil], ["city", "Lynchburg"], ["created_at", Fri, 01 Feb 2013 20:29:46 UTC +00:00], ["email", nil], ["facilities", nil], ["gmaps", true], ["lat", nil], ["latitude", 37.309589], ["long", nil], ["longitude", -79.114361], ["oldid", nil], ["phone", nil], ["photo_content_type", nil], ["photo_file_name", nil], ["photo_file_size", nil], ["photo_updated_at", nil], ["service_times", nil], ["title", nil], ["updated_at", Fri, 01 Feb 2013 20:29:46 UTC +00:00], ["zipcode", "24501"]]
   (198.5ms)  commit transaction

0 个答案:

没有答案