Flowdock
method

generate_full_message

Importance_2
v2.3.8 - Show latest stable - 0 notes - Class: ActiveRecord::Error
  • 1.0.0
  • 1.1.6
  • 1.2.6
  • 2.0.3
  • 2.1.0
  • 2.2.1
  • 2.3.8 (0)
  • 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
  • 6.1.7.7
  • 7.0.0
  • 7.1.3.2
  • What's this?
generate_full_message(options = {}) protected

Wraps an error message into a full_message format.

The default full_message format for any locale is "{{attribute}} {{message}}". One can specify locale specific default full_message format by storing it as a translation for the key :"activerecord.errors.full_messages.format".

Additionally one can specify a validation specific error message format by storing a translation for :"activerecord.errors.full_messages.[message_key]". E.g. the full_message format for any validation that uses :blank as a message key (such as validates_presence_of) can be stored to :"activerecord.errors.full_messages.blank".

Because the message key used by a validation can be overwritten on the validates_* class macro level one can customize the full_message format for any particular validation:

  # app/models/article.rb
  class Article < ActiveRecord::Base
    validates_presence_of :title, :message => :"title.blank"
  end

  # config/locales/en.yml
  en:
    activerecord:
      errors:
        full_messages:
          title:
            blank: This title is screwed!
Show source
Register or log in to add new notes.