ActiveRecord object.valid? triggers unexepected results

I'm editing an ActiveRecord object in a session through AJAX, updating it with object.attributes = params[:object], and validating it with object.valid? Because it's associated with other objects in a form, I want to save them all together.

The surprise was that object.valid? triggers after_validation_on_update. I'm having an audit log and I was getting bogus entries.

valid?() Runs validate and validate_on_create or validate_on_update and returns true if no errors were added otherwise false.

valid?() should run all validations, but not trigger after_validation callbacks. This is not just a rant... I'm looking for solutions? How can I have an audit log on updates and running valid()? without polluting my audit log?

Constantin Gavrilescu wrote:

How can I have an audit log on updates and running valid()? without polluting my audit log?

Well.. I gave my own answer. Replace after_validation_on_update with before_update. I think the misunderstanding came from the fact that I interpreted "after_validation on_update" when it actually was "after validation_on_update".