Hi,
From the ActiveRecord::Associations::ClassMethods docs, there is the
following:
“for post in Post.find(:all, :include => [ :author, :comments ])”
“That‘ll add another join along the lines of: LEFT OUTER JOIN comments
ON comments.post_id = posts.id”
What can one do to add a DYNAMIC second AND constraint to the left outer
join on clause such as:
“LEFT OUTER JOIN comments ON comments.post_id = posts.id AND
comment.person_id = ?”
I can only do this via a custom association where the comment.person_id
value is hard-coded, but it’s of very limited use. I want
comment.person_id to reflect the logged in user or a session id, etc.
(Perhaps a limitation of AR?)
I’ve always needed to go to find_by_sql for this and would LOVE to stay
with ActiveRecord, instead.
Many thanks,
J