diff options
author | eileencodes <eileencodes@gmail.com> | 2016-02-24 13:45:36 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2016-02-24 14:33:22 -0500 |
commit | 73f8c16601e51480d007dca5a33f2035293bdd23 (patch) | |
tree | 4781a2bad3c72de72a71298ef8d6b6cbbb51c4ba /guides/assets/images/oscardelben.jpg | |
parent | a5776ed2b2bf8bccb083e303992a174110b3ef7f (diff) | |
download | rails-73f8c16601e51480d007dca5a33f2035293bdd23.tar.gz rails-73f8c16601e51480d007dca5a33f2035293bdd23.tar.bz2 rails-73f8c16601e51480d007dca5a33f2035293bdd23.zip |
Ensure suppressor runs before validations
I ran into an issue where validations on a suppressed record were
causing validation errors to be thrown on a record that was never going
to be saved.
There isn't a reason to run the validations on a record that doesn't
matter.
This change moves the suppressor up the chain to be run on the `save` or
`save!` in the validations rather than in persistence. The issue with
running it when we hit persistence is that the validations are run
first, then we hit persistance, and then we hit the suppressor. The
suppressor comes first.
The change to the test was required since I added the
`validates_presence_of` validations. Adding this alone was enough to
demonstrate the issue. I added a new test to demonstrate the new
behavior is explict.
Diffstat (limited to 'guides/assets/images/oscardelben.jpg')
0 files changed, 0 insertions, 0 deletions