Method: ActiveModel::Errors#full_message

Defined in:
lib/reactive_record/active_record/errors.rb

#full_message(attribute, message) ⇒ Object

NOTE: Doesn’t use i18n

Returns a full message for a given attribute.

person.errors.full_message(:name, 'is invalid') # => "Name is invalid"


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/reactive_record/active_record/errors.rb', line 101

def full_message(attribute, message)
  return message if attribute == :base
  # TODO: When opal_activesupport 0.3.2 is released, use `humanize`
  # attr_name = attribute.to_s.tr('.', '_').humanize
  attr_name =
    attribute.to_s.tr('.', '_').tr('_', ' ').gsub(/_id$/, '').capitalize
  # attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
  # if @base.class.respond_to?(:human_attribute_name)
    attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
  # end
  # I18n.t(:"errors.format",
  #   default:  "%{attribute} %{message}",
  #   attribute: attr_name,
  #   message:   message)
  "#{attr_name} #{message}"
end