Skip to content
Advertisement

Complex JOIN with ActiveRecord and Rails 3

I have the following models:

I have to find all posts that belong to groups where user is a member. I have made it with this method:

but it produces unefficient SQL:

I want to make a query like this:

How can I do this without using raw SQL?

Advertisement

Answer

something like this should work for you, although it requires mixing in a little raw SQL

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement