Skipping validation sounds like a workaround. You're better off calling validations conditionally if there are cases when you don't want to validate. That way it's testable as well.
Up vote 0 down vote favorite share g+ share fb share tw.
I was using before_validation, to do a few updates to the models before they are being validated and later on - saved. Apparently, the validation callbacks aren't called when you save without validation. What callback should I use to make sure this code runs before the save and before validation if it exists?
Ruby-on-rails callback link|improve this question asked Feb 16 at 9:36Nadav475 80% accept rate.
Skipping validation sounds like a workaround. You're better off calling validations conditionally if there are cases when you don't want to validate. That way it's testable as well.
This seems pretty hacky but... def save do_something super end.
The reason to skip validations, is because some models are deadlocked together with validations (one is invalid before the other is changed, and vice versa). So, you save both models without validation and only then run the validations (all inside a transaction). – Nadav Feb 16 at 13:52 BTW, does that mean Rails doesn't support a callback that will happen before validation and saving?
– Nadav Feb 16 at 14:57 As far as I know, no. The Rails API lists the available callbacks in the order that they're available: api.rubyonrails.org/classes/ActiveRecord... – Tom L Feb 16 at 15:53 Sounds like there's a lot of interdependency going on in which case skipping validations is going to come back to bite you at some point. I'd reconsider that design.
That's easier said than done, I know. – Tom L Feb 16 at 16:22.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.