How can I hide activities with no user?

63 Views Asked by At

I'm trying to hide activities where their owners have deleted their accounts. So I added this

PublicActivity::Activity.order("created_at DESC").where( recipient: current_user).where.not(owner: nil)

but it returns

undefined method `image' for nil:NilClass

meaning it's adding activities with deleted users to the record. How can I hide them?

0

There are 0 best solutions below