ruby on rails - What is the rationale for `reject_if`? -


i've come across reject_if in cocoon's readme, , in documentation nested attributes. rationale using reject_if when associated active record objects can determine whether they're valid or not?

for nested objects, may not want attempt submit record :all_blank or other reason may want check on. point being, empty or incomplete (in way) object can, way, not built / added nested objects collection.

validations serve different purpose. if empty object, say, fails validation whole form submit fail. reject_if approach allows submission succeed in such case removing object consideration before validations fire.


Comments

Popular posts from this blog

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -