Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

accepts_nested_attributes_for broken after upgrade from 2.3.5 to 2.3.8

#4934

Hi,

accepts_nested_attributes_for :association is broken in one of my apps after upgrading to 2.3.8. The model itself is saved but the associations are not. I tried all different setups for the nested forms but it is definitely broken. For the time being I'm saving the associations separately.

Wout

Reported by wout · June 22nd, 2010 @ 07:59 PM

State: duplicate
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. wout
    wout

    I'v done some tests on three applications which all use nested forms. They were at 2.3.5 and I upgraded to 2.3.8. Now they all have the same symptoms, associations are saved on create but aren't saved on update.

    June 27th, 2010 @ 09:44 AM

  2. ebrahim
    ebrahim

    I've got a similar problem with Rails 2.3.5. This is my model: http://bitbucket.org/ebrahim/siva/src/a22fe3913315/app/models/word.rb
    If I uncomment the commented validates_size_of validation, no more child WordForm objects of word_forms are destroyed when they receive _destroy=1 attribute, and no error is reported. When that validation is commented, everything works as intended.
    I also checked in console: destroying some WordForm of a_word.word_forms does nothing and reports no errors.
    I also tried rewriting validate_size_of using a custom validation, but behavior was the same.
    I went back to Rails 2.3.5 and everything worked again, with validates_size_of enabled.

    July 10th, 2010 @ 03:24 PM

  3. ebrahim
    ebrahim

    I meant 2.3.8 in the first sentence.

    July 10th, 2010 @ 03:25 PM

  4. wout
    wout

    Thank you for noticing me about it.
    Commenting out the size validator did the trick indeed.

    I'm bumping all apps to Rails 3 anyway.
    I'l check if the same bug appears there.

    July 10th, 2010 @ 03:39 PM

  5. Neeraj Singh
    Neeraj Singh
    • State changed from new to duplicate
    • Importance changed from to Low

    @wout Rails3 has same issue with size validation.

    This ticket is duplicate of #2646 validations not called when model updating using nested attributes .

    July 10th, 2010 @ 05:14 PM