Class: SimpleForm::Errors

Inherits:
Hash
  • Object
show all
Defined in:
lib/simple_form/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(base, *args) ⇒ Errors

Returns a new instance of Errors.



27
28
29
30
# File 'lib/simple_form/errors.rb', line 27

def initialize(base, *args)
  @base = base
  super(*args)
end

Instance Method Details

#full_messagesObject



42
43
44
45
46
47
48
# File 'lib/simple_form/errors.rb', line 42

def full_messages
  map do |attribute, message|
    next if message.nil?
    attribute = attribute.to_sym
    "#{@base.class.human_attribute_name(attribute)} #{generate_message_for(attribute, message)}"
  end.compact.reverse
end

#on(attribute) ⇒ Object



35
36
37
38
39
40
# File 'lib/simple_form/errors.rb', line 35

def on(attribute)
  attribute = attribute.to_sym
  return nil unless self[attribute]

  generate_message_for(attribute, self[attribute])
end