I have the following modeling:
User
has_many :projects
Project
belongs_to :user
has_many :tasks
Task
belongs_to :project
has_many :workIntervals
WorkInterval
belongs_to :task
I have it as nested resources such as:
resources :projects do
resources :tasks do
resources :work_intervals
end
end
I get the user from the current_user who is signed in, that is why I don't have in the URL.
A WorkInterval from a Task is used to record the time(s) that the User has been working on a Task. So for example Monday from 10am to Tuesday at 10am. That is a task can have several WorkIntervals.
I would like to be able to have a button which would be "Start working" when I am in the task page. But I fail to see what would be what I should put in that button, is it an AJAX call? If so, what should I pass in the form_for? So, say the URL is:
/projects/:project_id/tasks/:task_id
And I want to have a button that is called "Start Working" than when triggered, creates a new WorkInterval associated with that task.
What would be the code to do a correct way to do so?