I want to be able to listen for and log validation errors when my models
are validated via save, save!, update_attribute, etc
I am looking for a hook like this: ActiveSupport::Notifications.subscribe
"validation.active_record"
It doesn't seem like there is one, perhaps there's a better approach? Or a
different hook?
I could monkeypatch activerecord, something like this, but it kind of
defeats the whole purpose of not getting entangled with ActiveRecord:
ActiveRecord::Validations.class_eval do
def perform_validations_with_instrumentation(options={})
ActiveSupport::Notifications.instrument("validation.active_record",
:object => self, :options => options) do
perform_validations_without_instrumentation(options)
end
end
alias_method_chain :perform_validations, :instrumentation
end
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/EQuhIAbla-UJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.