I’ve created a set of resources, with scaffolds that all work. I then
changed one resource to be nested inside another as a one to many
relation. This required a little bit of work on the tests, the
controllers and the views but it all works. Now I want to go the extra
step and have the child resources become updateable inside the parent
form. I’ve pushed the formatting of the child forms into partials which
I can call inside the parent form. This allows me to display a list of
the children inside a parent form. Standard stuff. Now the next step …
I want to use AJAX to update the child models inside the parent form.
The idea is that when I’ve got a list of the children on the parent
form, I can click the edit/delete links for a line and it will pull up
the edit form inside the parent form, allow me to edit the record, then
update it and close the section down again. I’ve got most of this done,
I can get as far as AJAXing an edit form for the child into the parent
form, updating that, which updates the activeRecord and then … Well
it still sends me off to the show method on the child controller, not
what I want so I have to do the next step and …
Someone else must have done this, I don’t want to have to re-invent the
wheel at every step, it’s such a common task there must be some good
step by step examples. But I can’t find them.
I’ve tried using ActiveScaffold which is OK, but it doesn’t really do
what I need it to do, and it’s broken in Rails 2.1, which requires
patching some fixes into the current code and the fixes are things that
were done ages and ages ago but aren’t in the current release and … ,
I’ve just not got the patience for this sort of thing. Which is why I
thought I’d do the job simply and cleanly by working forwards slowly
from the autogenerated scaffold code. So please don’t suggest
ActiveScaffold.
Any other suggestions?
If there really are no good examples for such a common design pattern
I’ll put up a solution somewhere public when I’ve done it. But I can’t
believe there isn’t one already.
Thanks
John S.