I would be very grateful if someone could help me with this.
I have a Tasks model, and Projects model. As you can imagine, Projects have many tasks and tasks belong to many projects.
I also have a table of relatoinships, where a task is related to a project.
What I don’t know how to do, is: I have a page where all the tasks are shown, and another page where all the projects are shown. I want the user to be able to select a task and assign it to a project. I don’t know how to pass the id of the selected task to the next page, where the projects are listed, and then with the id of the selected project create a relationship between those two id’s.
could someone help me on how to approach this? I’m not sure if I should use a cookie to save the value of the task, or if there is another way to do this..
thank you very much!
Joaquin (please excuse my english)
From what you’re describing you’ll probably want to do the association through the task’s form and then check all of the projects to which the task belongs. Your task form would look something like:
app/views/tasks/edit.html.erb:
Then, in your tasks_controller’s update method, you’d need something like:
And the link on your tasks list would be to the task’s edit page which contains the above ex: