ActiveRecord::UnknownAttributeReference: Query method called with non-attribute argument(s)
I’m trying to use spatial distance in my Rails app, but I keep running into the "ActiveRecord::UnknownAttributeReference: Query method called with non-attribute argument(s)" error when I try to use the order method. Here’s my code: def nearby_locations third_party_location_query = ThirdPartyLocation.where(id: id).select(‘geom’).to_sql third_party.organisation.locations.active. select("locations.*, ROUND(ST_DistanceSphere(locations.geom, (#{third_party_location_query}))::numeric, 0)::integer distance"). order("locations.geom <-> (#{third_party_location_query})"). limit(10).as_json(methods: [:distance]) end I understand… Read More ActiveRecord::UnknownAttributeReference: Query method called with non-attribute argument(s)