0

I keep getting the same error when I try to apply Geocoder gem to my search form. You will see 2 different queries in Event Controller. If I use them on their own they work great. But, I use them together, as shown here, it does throw the error.

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" .......

Event model

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

Event Controller

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

It seems like i had to specify table name for the Geocoder query. But, I have no idea how. Any help much appreciated!! Thanks

Sergio Nekora
  • 319
  • 1
  • 5
  • 19

1 Answers1

0

Probably the same Issue Geocoder SQLite3::SQLException: no such column: lon:. But I recommend you to go through the Geocoder documentation for Distance Queries in SQLite. And the rails cast. Hope this would help you.

Community
  • 1
  • 1
Anand Soni
  • 5,070
  • 11
  • 50
  • 101
  • Thanks for the quick answer. The rebooting did not work! I am aware of the limitations in SQLite. However, as far as I understand it should work. nope? There is also some info in here, https://github.com/alexreisner/geocoder/issues/42 . But to not avail. – Sergio Nekora Apr 16 '13 at 10:46
  • I am not sure but probably its a version of Geocoder problem. Are you trying with latest version ? In the link you have given one suggestion is to use gem from this branch : gem 'geocoder', :git => 'git://github.com/alexreisner/geocoder.git', :branch => 'no_grouping' Can you please try that ? – Anand Soni Apr 16 '13 at 11:04
  • I tried and got this error. fatal: ambiguous argument 'no_grouping': unknown revision or path not in the working tree. Use '--' to separate paths from revisions. What does it mean? – Sergio Nekora Apr 16 '13 at 11:16
  • Oh, I think the branch has removed from repository. Ok, get rid of it and try with MySQL, if that works – Anand Soni Apr 16 '13 at 11:18
  • I am using SQLite in development and PG in production. Should not work that way? I am using Heroku – Sergio Nekora Apr 16 '13 at 11:27
  • It should work. Have you added latitude:float longitude:float fields in modal ? Have you gone through RailsCast 273 episod ? He is using the same database and works for him. http://railscasts.com/episodes/273-geocoder?view=asciicast – Anand Soni Apr 16 '13 at 11:34
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/28307/discussion-between-anand-soni-and-sergio-nekora) – Anand Soni Apr 16 '13 at 11:37
  • yeap. That tutorial was my starting point. I got those two field in the model. When I use model.nearbys works fine. Even @events_casual = Event.non_timetable.near(params[:search_where], 20) works fine on its own. It just doesn't work when combined with the other query. At the same time, the other query also works on its own. – Sergio Nekora Apr 16 '13 at 11:38