ruby - Rails: validate number of associations -
How can you write verification for many organizations that are outdated? I have written something like this:
Validate the documents of the class: publication_count Personal def publication_count if publication count & gt; Template.component_count errors.add (: article, 'too many') Elsif publications count & lt; Template.component_count errors.add (: article, 'not enough') end end are both publication and template associations. I get a rollback error with this code, even if the record should be valid.
Your code appears correctly, so it seems that the associations are not set up properly or saved. going.
Have you tested this:
- Both the
publication and the template before you save it > Document assigned for example? - There is no rollback error for a different reason, such as the specificity failure?
- Is this the true belief that has been unsuccessful at any other?
Comments
Post a Comment