1
votes

I am trying to use Geocoder

I am trying to get results for the following query (I have this in my controller):

Event.near([params[:lat].to_f, params[:lng].to_f], params[:radius].to_f, unit: :km)

In my model I have:

geocoded_by :address, :latitude  => :lat, :longitude => :lng 
after_validation :geocode

but I get the following:

ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: lon: SELECT events.*, (69.09332411348201 * ABS(lat - -33.425329) * 0.7071067811865475) + (59.836573914187355 * ABS(lon - -70.604895) * 0.7071067811865475) AS distance, CASE WHEN (lat >= -33.425329 AND lon >= -70.604895) THEN  45.0 WHEN (lat <  -33.425329 AND lon >= -70.604895) THEN 135.0 WHEN (lat <  -33.425329 AND lon <  -70.604895) THEN 225.0 WHEN (lat >= -33.425329 AND lon <  -70.604895) THEN 315.0 END AS bearing FROM "events" WHERE (lat BETWEEN -33.714792566221696 AND -33.1358654337783 AND lon BETWEEN -70.95172225903696 AND -70.25806774096304) ORDER BY distance

Any help is appreciated

1

1 Answers

0
votes

This always happens... we should start by doing this before asking here: restart computer.

After rebooting the computer the problem was fixed...don't know why it was necessary do to it tho. Maybe something got stuck in memory and needed some hard reset..