Possible AJAX approach to nested data problem?

Greetings, I am curious to see if anyone can suggest an efficient approach to a problem I am having with nested AJAX forms which I am trying to avoid.

For example, let's say we have 3 models: 1. Problem (has_many :questions) 2. Question (belongs_to :problem, has_many :answers) 3. Answer (belongs_to :question)

I have a form that allows a user to document a problem.

Also, the user is able to pose 0..n questions for the documented problem and then 0..n possible answers for each question posed.

I was using a form_remote_tag to add questions on the problem form page by using the form_remote_tag to call a method that returns another ajax form (form_remote_tag) to do add any possible answers to the question. I know, I know nested forms-ugh.

The returned answers are showing up in the wrong DOM elements; I'm pretty sure I can develop a workaround, but I am getting this feeling that I used to when using Java and JSPs and AJAX where code starts getting real convoluted. I am sure there are some Rails hackers out there that can suggest a cleaner, more Railesque way. Form.serialize perhaps?

Thanks-David

The question I have for the community is how you, in general, would approach such a problem. Would you use AJAX type forms to keep a user on one page or would you split it up.

The question I have for the community is how you, in general, would approach such a problem. Would you use AJAX type forms to keep a user on one page or would you split it up.

3 Options

1) Dont use nested forms, because - quite simply - they dont work. (easiest) 2) Use link_to_remote :with (wont support multipart) 3) Use modal windows ala lightbox. (looks pretty)

Thanks Matt, I have kind of reached conclusion 1. I'll peek at a lightbox approach and maybe even an IFRAME. Thanks again-David