I keep track of the following tables:
Story (id, user_id, content)
Vote (id, user_id, story_id)
Flag (id, user_id, story_id)
etc..
with action table:
Activity (id, user_id,action, trackable_id, trackable_type)
Relations table:
Relationship (id, follower_id, followed_id)
I am currently receiving actions from users that follow as follows:
def get_activity_from_followers(current_user)
followed_user_ids = "SELECT followed_id FROM relationships
WHERE follower_id = :user_id"
where("user_id IN (#{followed_user_ids})",
user_id: user.id)
end
My question is: how do I get the actions in which you have a tracked table (for example, history, voice, flag).
So right now I'm getting things like:
- "someone you follow" posted a story
- "someone you follow" voted for the story
I also want to get things like:
- "someone you don't follow" voted for your story.
- "someone you don't follow" is tagged with your story
How can I do it? Thank.