ryanb / nested_form

Rails plugin to conveniently handle multiple models in a single form.
MIT License
1.79k stars 506 forks source link

JavaScript bug when the parent of a deeply nested attribute is not in a "many" relationship. #26

Open pirelenito opened 13 years ago

pirelenito commented 13 years ago

The fix proposed in ryanb/nested_form#19 is not complete:

Actually there is still a bug regarding this scenario:

In a Root embeds_one Child embeds_many DeepChild, the name of a deeply nested field would be:

root[child_attributes][deep_child_attributes][0][attribute]

The javascript code responsible to fill the blueprint's parent's ids is broken, since it is always expecting an index after an /[a-z]+attributes/g ex:

root[child_attributes][0][deep_child_attributes][0][attribute]

ryanb commented 13 years ago

Thanks for reporting this. I'll mark this to be fixed in the code.

ryanb commented 13 years ago

I pulled in the change from @eljuanchosf which should fix this problem. Let me know if it doesn't and I'll re-open.

garrettlancaster commented 11 years ago

This problem is still happening for me

lest commented 11 years ago

@garrettlancaster Could you please push a test application reproducing your issue?

garrettlancaster commented 11 years ago

Sure thing, here is the link: https://github.com/garrettlancaster/nested_form_failing. Let me know if you need anything else.

garrettlancaster commented 11 years ago

Oh, and make sure to add at least two gifts. It works if you only add one.

Overview of the contrived example: Person belongs_to Birthday Birthday has_many Gifts

lest commented 11 years ago

@garrettlancaster Thanks! I'll take a look.

gedean commented 11 years ago

It happens to me too.

garrettlancaster commented 11 years ago

any progress on this?

eljuanchosf commented 11 years ago

Es cierto, debería, pero por algún motivo no sucede lo que debería suceder.

Habría que identificar en donde se produce el cambio.

Abrazo!

On Sat 23 Apr 2011 02:06:28 PM ART, ryanb wrote:

I pulled in the change from @eljuanchosf which should fix this problem. Let me know if it doesn't and I'll re-open.

Mis mejores deseos, Best wishes, Meilleurs vœux,

Juan Pablo

http://www.jpgenovese.com