I’m trying to fetch some posts from users that isn’t blocking “me”. Se models below:
User
id
username
....
Post
id
user_id
content
...
Blockings
blocker_id
blocked_id
I need to fetch posts from all users that isn’t blocking me.
I fetch all posts with:
@posts Post.all
But how do I joins this together.
Pseudo
SELECT * FROM posts WHERE "posts.user_id isn't blocking me"
I have a helper called current_user that returns the current logged in user “me”.
A way to do it with SQL would be:
Just replace the numerical id with the variable.
SQL Fiddle