:through not working as I expected

I'm guessing your court_users table doesn't have a task_id column.