Class: ActiveModel::BetterErrors::HumanMessageFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/active_model/better_errors/human_message_formatter.rb

Overview

HumanMessageFormatter

Instance Attribute Summary

Attributes inherited from Formatter

#base, #error_message

Instance Method Summary collapse

Methods inherited from Formatter

#initialize

Constructor Details

This class inherits a constructor from ActiveModel::BetterErrors::Formatter

Instance Method Details

#format_messageObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/active_model/better_errors/human_message_formatter.rb', line 9

def format_message
  return message if message

  keys = i18n_keys
  key  = keys.shift

  options = {
    default: keys,
    model: base.class.model_name.human,
    attribute: base.class.human_attribute_name(attribute),
    value: value
  }.merge(self.options)

  I18n.translate key, options
end