当我尝试将 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 查询指定表名。但是,我不知道怎么做。非常感谢任何帮助!谢谢