I have a collection of posts from current_user and other 'followed' users displayed in a list. Posts can be marked anonymous on submit which hides the posters name (there is an 'anon column in the posts database that is either 1 or 0')
In my collection of posts, I want to show anonymous posts for the current_user, but exclude the anonymous posts from other users.
Here's what I have in my controller:
@feed = current_user.feed.where('anon != ?', '1')
The problem is it excludes all anonymous posts in my list.
Any ideas?
update:
Here is my feed method:
def feed
following_other_ids = "SELECT followable_id FROM follows
WHERE followable_type = 'Other' AND follower_id = :user_id"
following_user_ids = "SELECT followable_id FROM follows
WHERE followable_type = 'User' AND follower_id = :user_id"
Post.where("other_id IN (#{following_other_ids})
OR user_id IN (#{following_user_ids})
OR user_id = :user_id", user_id: id)
end