I'm not sure this will work long term. The ordering is based on the task id field which is arbitrary and doesn't represent the order of the tasks. The task definitions are what contain the order. If you were to use something like "assigment.tasks.for_display" (which joins the task definition information with tasks), you can then order them by the "position" column which will give you the actual order. Actually, you may even be able to determine the previous/next based on the position alone and not even have to query the entire list of tasks. If position is more than 1, then previous is one less. If position is less than task count, then next is one more. Either way works... the main thing is to get it ordering by the more reliable column.