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.

autosave behavior not consistent between has_many and has_one

#5339

I have described the problem in detail in this blog. http://neeraj.name/2010/08/09/autosave-option-in-rails.html

Reported by Neeraj Singh · August 9th, 2010 @ 04:08 PM

State: invalid
Milestone: 3.x
Assigned to: Neeraj Singh Neeraj Singh
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh
    • Assigned user set to Neeraj Singh

    August 9th, 2010 @ 05:03 PM

  2. José Valim
    José Valim
    • State changed from new to invalid

    The inconsistency is not in :autosave, but the fact :validate is true by default for has_many but false for has_one. It works this way for a long time (I'm not aware of the reason) but I'm sure we cannot change the default as it will cause massive breakage.

    August 9th, 2010 @ 06:35 PM

  3. Neeraj Singh
    Neeraj Singh

    Don't worry that in has_one because of lack of validation invalid record will get in. That won't happen. Validation still happens.

    • if autosave is not declared
    • if child is invalid
    • then has_one will persist the parent record but reject child record.
    • then has_many will reject both parent and child record.

    That's the inconsistency.

    Just wanted to clarify that in both the cases invalid record will not get persisted :-)

    August 9th, 2010 @ 06:48 PM