Geocoder + Rails 3.2 // SQLException:没有这样的列:距离:

时间:2013-04-16 10:19:50

标签: ruby-on-rails ruby-on-rails-3 sqlite rails-geocoder

当我尝试将Geocoder gem应用于我的搜索表单时,我一直收到同样的错误。您将在事件控制器中看到2个不同的查询。如果我自己使用它们,它们会很好用。但是,我一起使用它们,如图所示,它确实会抛出错误。

QLite3::SQLException: no such column: distance: SELECT "events"."id" AS t0_r0, "events"."header_id" AS t0_r1, "events"."start_date" AS t0_r2, "events"."finish_date" AS t0_r3, "events"."address" AS t0_r4, "events"."place" .......

活动模型

scope :non_timetable, joins(:header).where(headers: {weekly: false})

事件控制器

def search

@events_casual = Event.non_timetable.near(params[:search_where], 20)
@events_casual  = @events_casual.where("events.finish_date >= ?", @time).where((["CAST(headers.title_es as varchar(255)) LIKE ?", "%#{params[:query]}%"] || ["CAST(headers.title_en as varchar(255)) LIKE ?", "%#{params[:query]}%"] || ["CAST(headers.title_eu as varchar(255)) LIKE ?", "%#{params[:query]}%"] || ["CAST(headers.title_fr as varchar(255)) LIKE ?", "%#{params[:query]}%"])).includes(:header).order("events.start_date ASC")
...

end

似乎我必须为Geocoder查询指定表名。但是,我不知道如何。任何帮助非常感谢!!感谢

1 个答案:

答案 0 :(得分:0)

可能是同一个问题Geocoder SQLite3::SQLException: no such column: lon:。但我建议您浏览Distance Queries in SQLite的Geocoder文档。和rails cast。希望这会对你有所帮助。