So I want to SELECT from multiple tables, so as to be able to do
“SELECT FROM foo, bar WHERE foo.id=bar.id AND bar.baz=23”.
How do I do it with AR#find?
Also, I need this for associations. has_many et. al. have :finder_sql,
which is nice, but feels like a Pyrrhic: it’s basically doing the
association in pure SQL, defeating the purpose of AR.
“:include: Names associations that should be loaded alongside using
LEFT OUTER JOINs. The symbols named refer to already defined
associations. See eager loading under Associations.”
So it wasn’t intended for this but… it works!
My guess is that the :include adds table bar to the SELECT, so WHERE
can refer to it in the same query when you specify it in conditions.
Using it qualifies as a hack, imho
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.