Arel and Nested Queries
Arel is good at facilitating conditional clauses. This post mainly focuses on
how to write nested queries with Arel.
Let's look at a simple nested select example:
SELECT *
FROM (
SELECT *
FROM users
WHERE users.id < 100 ) as old_users
One way to implement this is mixing ActiveRecord…