Class ActiveRecord::Errors
In: vendor/plugins/globalize/lib/globalize/rails/active_record.rb
Parent: Object

Overrode Errors methods to handle numbers correctly for translation, and to automatically translate error messages. Messages are translated after the field names have been substituted.

Methods

Public Instance methods

Like the regular add, but automatically translates the error message. Takes an extra num argument to support pluralization.

[Source]

    # File vendor/plugins/globalize/lib/globalize/rails/active_record.rb, line 10
10:     def add(attribute, msg = @@default_error_messages[:invalid], num = nil)
11:       @errors[attribute.to_s] = [] if @errors[attribute.to_s].nil?
12:       @errors[attribute.to_s] << [ msg, num ]
13:     end

Like the regular add_on_boundary_breaking, but automatically translates the error message.

[Source]

    # File vendor/plugins/globalize/lib/globalize/rails/active_record.rb, line 22
22:     def add_on_boundary_breaking(attributes, range, 
23:         too_long_msg = @@default_error_messages[:too_long], 
24:         too_short_msg = @@default_error_messages[:too_short])
25:       for attr in [attributes].flatten
26:         value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s]
27:         add(attr, too_short_msg, range.begin) if value && value.length < range.begin
28:         add(attr, too_long_msg, range.end) if value && value.length > range.end
29:       end
30:     end

Like the regular add_to_base, but automatically translates the error message. Takes an extra num argument to support pluralization.

[Source]

    # File vendor/plugins/globalize/lib/globalize/rails/active_record.rb, line 17
17:     def add_to_base(msg, num = nil)
18:       add(:base, msg, num)
19:     end

[Validate]