I am working on a problem where I have a large task that is broken
down into a lot of subtasks. The subtasks each take a significant
amount of time to do. My data model looks something like this:
class LargeTask < ActiveRecord::Base
class SubTask < ActiveRecord::Base
When I create the large task, it creates all of the subtasks on its
own and populates them with the data that they need to run, and saves
them. It doesn’t actually perform the subtask until I call a method
on the subtask object.
What I am thinking is that when I create a new LargeTask, it will
redirect to the show action of that LargeTask, and will display all of
the subtasks in a list. I will then use AJAX to one-at-a-time call
the Run action on each of the SubTasks and have it update the section
of the page that it is displaying. When one gets finished running,
next task. Basically I want to give the user visual feedback of where
in the process they are.
Is there a way that I can use the AJAX functionality built into rails
to make this happen without having to do some sort of custom control
mechanism to track all of the SubTasks on the client side? Or is
there a better strategy to go about this?
The SubTasks do not need to be run in any particular order. I will
probably eventually run 2 or 3 at a time.
Any suggestions? Thanks in advance.