generate_message (ActiveRecord::Errors)

    # File lib/active_record/validations.rb, line 88
        def generate_message(attribute, message = :invalid, options = {})

          message, options[:default] = options[:default], message if options[:default].is_a?(Symbol)

          defaults = @base.class.self_and_descendents_from_active_record.map do |klass|
            [ "models.#{klass.name.underscore}.attributes.#{attribute}.#{message}""models.#{klass.name.underscore}.attributes.#{attribute}.#{message}",
              "models.#{klass.name.underscore}.#{message}""models.#{klass.name.underscore}.#{message}" ]
          end

          defaults << options.delete(:default)
          defaults = defaults.compact.flatten << "messages.#{message}""messages.#{message}"

          key = defaults.shift
          value = @base.respond_to?(attribute) ? @base.send(attribute) : nil

          options = { :default => defaults,
            :model => @base.class.human_name,
            :attribute => @base.class.human_attribute_name(attribute.to_s),
            :value => value,
            :scope => [:activerecord, :errors]
          }.merge(options)

          I18n.translate(key, options)
        end