I am getting this error some time and some time not. That is strange.
ERROR: syntax error at or near ")" LINE 1: SELECT locations.*, () as distance FROM "locations" ORDER ...
In line
nearby_locations.includes(:events).each do |location|
In my Dashboard controller
def home
nearby_locations = Location.with_distance_to(remote_ip).order('distance').limit(10)
@events = []
nearby_locations.includes(:events).each do |location|
@events += location.events.where("publish = true")
end
end
In my Location.rb model
geocoded_by :address
extend Geocoder::Model::ActiveRecord
reverse_geocoded_by :latitude, :longitude
scope :with_distance_to, ->(point) { select("#{table_name}.*").select("(#{distance_from_sql(point)}) as distance") }