Having a devil of a time finding records in a self-referencing has_many
Everything is working find looking at the has_many and the belongs_to
But, when I try to find all “orphans”, records that are neither a parent
nor a child, I can not find a query that work in ActiveRecord.
This query works in MySQL:
SELECT * FROM templates
LEFT JOIN templates t2 ON templates.id=t2.template_id
WHERE (t2.id IS NULL AND templates.template_id IS NULL)
Of course, the table alises through ActiveRecord for a loop when
manually entered in the :joins options.