Module: ActiveRecord::Validations::ClassMethods

Defined in:
lib/gettext/active_record.rb

Overview

:nodoc:

Constant Summary collapse

@@custom_error_messages_d =
{}

Instance Method Summary collapse

Instance Method Details

#custom_error_messages_dObject

:nodoc:



110
111
112
# File 'lib/gettext/active_record.rb', line 110

def custom_error_messages_d  #:nodoc:
	@@custom_error_messages_d
end

#validates_length_of_with_gettext(*attrs) ⇒ Object

Very ugly but…



99
100
101
102
103
104
105
106
107
# File 'lib/gettext/active_record.rb', line 99

def validates_length_of_with_gettext(*attrs)  #:nodoc:
	if attrs.last.is_a?(Hash)
	  msg = attrs.last[:message] || attrs.last[:too_long] || attrs.last[:too_short] || attrs.last[:wrong_length]
	  if msg
	    @@custom_error_messages_d[msg] = /\A#{Regexp.escape(msg).sub(/%d/, '(\d+)')}\Z/ 
	  end
	end
	validates_size_of(*attrs)
end