Rails Plugin to track validation errors
Even if we add the most explaning error messages and make use of some good practices to do so, users simply don´t read error messages. One of the most 开发者_StackOverflowrecurring support that we have are errors already covered by validations not read by our users.
Our software has a control panel for the support people to have quick access to any usefull information they might need to provide a quick and quality support.
I want to add to this control panel a list of last validation errors per user so we can rapidly identify if the problem users are facing are just validation problems.
Are there any plugins that allow me to write a callback to any validation error in any model in my app?
I´d love to be able to write something like this
def on_any_validation_error(model, params)
#my logic to add to some log control database backed or not
end
I don't know if a plugin like that exists but I've just played a bit with the after_validation callback, you could write an initializer with something like the following:
def log_errors
log(self) unless errors.blank?
end
ActiveRecord::Base.send(:after_validation,:log_errors)
Then you have to implement your logic in the log method.
精彩评论