I am trying to convert this query into the active record but don't get any luck. Can anyone guide me how to convert this query from raw SQL to active record query
select users.* from
(
select email from players_schema.inv_emails where inv_emails.created_at <= (current_date - interval '14 days')
union
select email from players_schema.blks where blks.created_at <= (current_date - interval '14 days')
union
select email from players_schema.bouces where bouces.created_at <= (current_date - interval '14 days')
) email
join football_schema.users on users.email = email.email;
I am using rails 4.2