method
full_message
v6.1.3.1 -
Show latest stable
-
0 notes -
Class: Error
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
full_message(attribute, message, base)
public
Hide source
# File activemodel/lib/active_model/error.rb, line 15 def self.full_message(attribute, message, base) # :nodoc: return message if attribute == :base base_class = base.class attribute = attribute.to_s if i18n_customize_full_message && base_class.respond_to?(:i18n_scope) attribute = attribute.remove(/\[\d+\]/) parts = attribute.split(".") attribute_name = parts.pop namespace = parts.join("/") unless parts.empty? attributes_scope = "#{base_class.i18n_scope}.errors.models" if namespace defaults = base_class.lookup_ancestors.map do |klass| [ :"#{attributes_scope}.#{klass.model_name.i18n_key}/#{namespace}.attributes.#{attribute_name}.format", :"#{attributes_scope}.#{klass.model_name.i18n_key}/#{namespace}.format", ] end else defaults = base_class.lookup_ancestors.map do |klass| [ :"#{attributes_scope}.#{klass.model_name.i18n_key}.attributes.#{attribute_name}.format", :"#{attributes_scope}.#{klass.model_name.i18n_key}.format", ] end end defaults.flatten! else defaults = [] end defaults << :"errors.format" defaults << "%{attribute} %{message}" attr_name = attribute.tr(".", "_").humanize attr_name = base_class.human_attribute_name(attribute, { default: attr_name, base: base, }) I18n.t(defaults.shift, default: defaults, attribute: attr_name, message: message) end