I’m new to Rails and having a go at a twitter type web app.
The ‘following’ and ‘followers’ part of the app is fine. However I want to filter the Posts index to only show posts that the current user is following.
I need to do something along the lines of:
@posts = Post.where('user_id LIKE ?', current_user.friendships )
As I expected this throws up an error
SQLite3::SQLException: near ",": syntax error: SELECT "posts".* FROM "posts" WHERE (user_id LIKE 8,9)
It seems close to what I want because 8,9 are the id’s of the friends I am following.
Any suggestions as to the best way to get what I’m looking for?
Thanks!
Try
INinstead ofLIKE:Or: