3

我正在使用Geocoder gem,并且提到了这个片段用于搜索远处的记录:

Venue.near('Omaha, NE, US', 20)

这运作良好,但我需要添加另一个条件。这是我目前使用的查询:

   Car.where('car.status = ? AND listings.sold IS ?', 1, nil).includes(:images, :user)

对于这个查询,我正在尝试添加调用,如下所示:

Car.near('90013', 20).('car.status = ? AND listings.sold IS ?', 1, nil).includes(:images, :user)

但是这个查询的结果只是nil

将附近查询与where条件相结合的正确方法是什么?

4

1 回答 1

1
nearest_location = @company.work_groups.where("level = 1 AND wg_active = 1 AND address IS NOT NULL AND address <> ''").near(employee_location, @company.miles, :order => :distance).first

这是我在同一行代码中使用 Geocoder gem 和 where 语句的示例。希望它有所帮助。

于 2013-09-12T09:47:57.540 回答