mirror of
https://github.com/internetee/registry.git
synced 2025-05-28 15:19:55 +02:00
Log all activerecord and activemodel user issues #2808
This commit is contained in:
parent
09deb2b187
commit
dd7771c59d
5 changed files with 26 additions and 2 deletions
18
config/initializers/eis_custom_active_model.rb
Normal file
18
config/initializers/eis_custom_active_model.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Log all active model user errors
|
||||
module ActiveModel
|
||||
class Errors
|
||||
def add(attribute, message = :invalid, options = {})
|
||||
message = normalize_message(attribute, message, options)
|
||||
if exception = options[:strict]
|
||||
exception = ActiveModel::StrictValidationFailed if exception == true
|
||||
raise exception, full_message(attribute, message)
|
||||
end
|
||||
|
||||
# CUSTOM logging
|
||||
Rails.logger.info "USER MSG: #{Time.now.to_s(:db)} ACTIVEMODEL: #{@base.try(:class)} [#{attribute}] #{message}" if message.present?
|
||||
# END of CUSTOM logging
|
||||
|
||||
self[attribute] << message
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue