Job has many task, task has many notes
How should such a form look like ? With partials so I can enter the whole job from /jobs/new , and add new tasks from /jobs/2/tasks/new with possibility to add notes from there, and of course the possibility to add new notes from /jobs/2/tasks/5/notes/new ?
Is this a good place to use the presenter pattern ? When yes, which library should I use ?
I have tried the rails3 branch of active_presenter on github but I had some troubles with the form partials.
Have somebody a good example for such a task ?
There are plenty of presenter tutorials, nested forms tutorials, and unobtrusive javascript tutorials, but not only one have explained all together.
It would be nice if someone pasted a tutorial using html5 and rails3 examples
Presenter pattern isn’t necessarily the best fit here, actually.
You’ll probably get futher by just using
accepts_nested_attributes_for:And then in your form doing something like (in HAML):
You may have to actually initialise some tasks/notes for new jobs or the associated record forms might not show up. E.g., do something like
3.times { @job.tasks.build }to create 3 blank tasks (and therefore display the task sub-form 3 times).