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

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -