Module: Nexx::AdvancedErrors::FullMessages

Defined in:
lib/advanced_errors/full_messages.rb

Constant Summary collapse

REGEX =
/^\^/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



18
19
20
21
22
23
# File 'lib/advanced_errors/full_messages.rb', line 18

def self.included(base)
  base.class_eval do
    alias_method :full_messages_without_ignore_attribute, :full_messages
    alias_method :full_messages, :full_messages_with_ignore_attribute
  end
end

Instance Method Details

#full_messages_with_ignore_attributeObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/advanced_errors/full_messages.rb', line 6

def full_messages_with_ignore_attribute
  error = ActiveRecord::Errors.new @base
  self.each do |attribute, message|
    unless message.match(REGEX)
      error.add attribute, message
    else
      error.add_to_base message.sub REGEX, ''
    end
  end
  error.full_messages_without_ignore_attribute
end