The SQL example in section 12.1.1 references ‘clients’, and I believe it was meant to reference ‘authors’. Very minor, but it confused me at first. Hope this helps.
Hey @taarnac, do you have a link to the problematic guide?
Good afternoon, Lewis.
I had to do some searching because I looked at the documentation and it looked different from what I was describing.
So after, some more research, I realized that (palm to forehead) I had been looking at an older version of documentation, and the issue has since been resolved.
FWIW, here is the info:
12.1.1 Using a String SQL Fragment
You can just supply the raw SQL specifying the JOIN clause to joins:
Author.joins(“INNER JOIN posts ON posts.author_id = author.id AND posts.published = ‘t’”)
This will result in the following SQL:
SELECT clients.* FROM clients INNER JOIN posts ON posts.author_id = author.id AND posts.published = ‘t’
Sorry to have wasted your time. I was just trying to be helpful.
No worries! Glad it’s been updated already!
Facing same Issue. Did you find any solution.
Good morning, Bruce.
The issue was that the example statement joins ‘Author’ and ‘Posts’, but the SQL in the example is joining ‘Clients’ and ‘Posts’.
I think whoever was doing the documentation cut-and-pasted from another example and forgot to change the table name.
However, I later found that the example I was looking at came from an earlier version of the documentation (I think it was V5.1) and it had since been corrected in more recent versions.