我有两个任务数组-创建和分配。我想从创建的任务数组中删除所有分配的任务。这是我的工作代码,但很混乱:
@assigned_tasks = @user.assigned_tasks
@created_tasks = @user.created_tasks
#Do not show created tasks assigned to self
@created_not_doing_tasks = Array.new
@created_tasks.each do |task|
unless @assigned_tasks.include?(task)
@created_not_doing_tasks << task
end
end
我敢肯定有更好的方法。它是什么?谢谢 :-)