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
Post a Comment