I run this SQL statement
select * from checkins where user_id in (SELECT friend_id from friendships where user_id=1);
Users Table
id | name | email
Friendships Table
user_id | friend_id
Checkins Table
user_id | checkin_time
I’ve tried
friends = Friendship.select("friend_id").where("user_id = 1");
Checkin.where("user_id = "+friends);
Any ideas on how to rewrite this with Active Record? I feel like there should be a simple way to pull this out…
How about:
or, for something more like your original idea: