I’m sure there’s something right under my nose that I’m missing. I
have two tables with two parallel one-to-many relationships. I wish to
use the :finder_sql parameter to essentially ‘or’ the two foreign
keys.

What isn’t working for me is performing a ‘sub-search’.

Let’s say the tables are “stores” and “people,” and the relationships
are called “works_for” and “shops_at.”

I want to have a single “has_many” relationship that encompasses the
people who visit a store. Something like:

Like all text messages, email exchanged with a gmail account may be
stored indefinitely and/or read by third parties without the sender or
receiver’s knowledge or permission. Please do not send any privileged
or confidential transmission to this account: enquire about secure
alternatives.

Actually, he’s correct. When you define the finder_sql in the model
class, you have no clue what id will be. It’s defined in single
quotes so that #{id} gets parsed at query time with the current id
value.

As for the original question, I believe having a defined finder_sql
forces it to ignore the other attributes such as order and conditions.
It looks like you’re using two shop_id foreign keys in the people
table for duplicate purpose with STI. Why not simplify the schema a
bit?

Like all text messages, email exchanged with a gmail account may be
stored indefinitely and/or read by third parties without the sender or
receiver’s knowledge or permission. Please do not send any privileged
or confidential transmission to this account: enquire about secure
alternatives.