This project is archived and is in readonly mode.
autosave behavior not consistent between has_many and has_one
-
Neeraj Singh
- Assigned user set to Neeraj Singh
-
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.
-
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 :-)