Sha256: 6405ad6522a56258ed67a3a4c1afe5a54d8afb8d0d2faf97bfca1caf3d8cbfc8
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
if defined?(ActiveRecord::Errors) # The following is taken from custom_error_message plugin by David Easley # (http://rubyforge.org/projects/custom-err-msg/) module ActiveRecord class Errors # Redefine the ActiveRecord::Errors::full_messages method: # Returns all the full error messages in an array. 'Base' messages are handled as usual. # Non-base messages are prefixed with the attribute name as usual UNLESS they begin with '^' # in which case the attribute name is omitted. # E.g. validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service' def full_messages full_messages = [] @errors.each_key do |attr| @errors[attr].each do |msg| next if msg.nil? if attr == "base" full_messages << msg elsif msg =~ /^\^/ full_messages << msg[1..-1] else full_messages << @base.class.human_attribute_name(attr) + " " + msg end end end return full_messages end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
yaroslav-russian-0.0.1 | lib/russian/active_record_ext/custom_error_message.rb |
russian-0.0.1 | lib/russian/active_record_ext/custom_error_message.rb |