method

generate_full_message

rails latest stable - Class: ActiveRecord::Error

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

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!