Sha256: 86a3391ec12a098d718e0ddfe6b43142ec5d366b25b5491feb3be6f73178fc6b

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

require "activemodel/error_messages_without_attributes/version"

require 'active_model'
require 'active_support'

module ActiveModel
  class Errors
    alias_method :original_full_message, :full_message

    # if the error message starts with "^", then don't prepend the attribute name
    def full_message(attribute, message)
      return message if attribute == :base

      if message =~ /\A\^/
        I18n.t(:"errors.format.full_message", {
          default: "%{message}",
          message:  message[1..-1]
        })
      else
        original_full_message(attribute, message)
      end
    end
  end
end

ActiveSupport.on_load(:i18n) do
  I18n.load_path << File.dirname(__FILE__) + '/locale/en.yml'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activemodel-error_messages_without_attributes-0.1.0 lib/activemodel/error_messages_without_attributes.rb