Try Post.where(user_id IN (?) OR topic_id IN (?), [1,2], [4,5])
Post.where(user_id IN (?) OR topic_id IN (?), [1,2], [4,5])