ruby on rails - How to capture all ActiveRecord::Errors under config/initializersin Rails3 -
i trying configure applications print errors activerecord object in app. can avoid printing error message each object in place of transactions. there way this?
need somethind this
in config/initializers
activerecord::base.class_eval # each active_record object in app if self.errors.any? puts self.errors.inspect end end
i believe want have ar errors in 1 place,
one method using rescue_from. in application controller
class applicationcontroller < actioncontroller::base protect_from_forgery with: :exception #your normal code rescue_from exception |exeception| #check if ar exception #if yes #log in different log file #if not # yield (to follow default exception chain) end end more proper way have in module , include in applciationcontroller.
hth
Comments
Post a Comment