To date, I have only been able to run a find_by_sql query involving all records of two tables to find Intersects.
Regionpolygon.where('nation_id = ?', 74).find_by_sql "SELECT regionpolygons.id, area_name, destinations.id
FROM regionpolygons, destinations
WHERE ST_Intersects(regionpolygons.polygon_area, destinations.latlon)"
Two goals which need to be achieved are:
- having a smaller subset from which to query regionpolygons
@rps = Regionpolygon.where('nation_id = ?',74).allThis appears to work.. - providing a single point from the destinations table
@dests = Destination.all @dests.each do |dest| [...]so that an iteration can allow for updating record attributes instance variables do not appear to be well digested when added to this type of query
How can this query be formulated?