I'm using Public Activity to create a feed, and I'd like to filter the activities. I don't want to show to the current_user its own activities so I have:
@activities = PublicActivity::Activity.where.not(owner_id: current_user.id)
And this works well. I want to add a second filter, which is to only display activities that belong to the users followed by current_user.
I can get all the followed users using:
@users = current_user.following
My question is: how can I filter the activities by checking if owner_id is the id of a user included in @users ?
EDIT:
activities table:
create_table "activities", force: :cascade do |t|
t.integer "trackable_id"
t.string "trackable_type"
t.integer "owner_id"
t.string "owner_type"
t.string "key"
t.text "parameters"
t.integer "recipient_id"
t.string "recipient_type"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "read", default: false
t.string "origin"
end