Rails3: how to use relational algebra to replace SQL-constructions like NOT and OUTER JOIN
- by petRUShka
There are two models Post and Comment. I should get all posts, which have no comments with specific tag. How can I do this using new Rails 3 features such relational algebra (arel).
SQL-solution should be something like this:
SELECT `posts`.* FROM `posts` LEFT OUTER JOIN `comments` ON `posts`.`id` = `comments`.`post_id`
WHERE NOT (`comments`.`tag` = 'my_tag')