Simple_Form prepopulate associations

38 views
Skip to first unread message

jrode...@outlook.com

unread,
Jul 14, 2017, 7:28:23 AM7/14/17
to SimpleForm
Hello,

I have the following structure
Projects has_many tasks
Task has_many task_objects
Task has_many_teams

I have implemented the usual workflow without problem but am looking to add a category field to project that will then auto-generate a pre-defined set of associated tasks and task_objects 
eg If I choose a project of category Event I'd like the form to auto-generate tasks for travel & venue with their associated task_object fields such as travel from, travel to and location

Has any one implemented something similar? I'd really appreciate it if someone could point me in the right direction.


John Athayde

unread,
Jul 14, 2017, 8:15:04 AM7/14/17
to plataformate...@googlegroups.com
How are you storing the tasks by type? Are those DB objects or just things that you are going to build in the controller? Are your categories actually models that have logic associated with them or is it not that complex?

Cheers
J

John Athayde
202.285.3544 (m)
CargoSense | www.cargosense.com
Meticulous | www.meticulous.com

Jamie

unread,
Jul 14, 2017, 9:19:43 AM7/14/17
to SimpleForm
Hi John,

Project, Tasks, TaskObjects & Teams are separate models with their own controllers
Currently in the Project form there is a drop down for project_type (I'm not using Single Table Inheritance on the Project model). 
Then, using link_to_add_association I can add tasks and each task has a project_id.
Within a task you can add more associations for TaskObjects and Teams. TaskObjects and Teams have a task_id

Reply all
Reply to author
Forward
0 new messages