Class | ActiveRecord::Errors
In: | lib/gloc-rails.rb
Parent: | Object

### Methods

add current_language

### Included Modules

GLoc

### External Aliases

add | -> | add_without_gloc

### Public Instance methods

add(attribute, msg= @@default_error_messages[:invalid])

The GLoc version of this method provides two extra features

- If `msg` is a string, it will be considered a GLoc string key.
- If `msg` is an array, the first element will be considered the string and the remaining elements will be considered arguments for the string. Eg. `[‘Hi %s.’,’John’]`

[Source]

         # File lib/gloc-rails.rb, line 141
    141:     def add(attribute, msg= @@default_error_messages[:invalid])
    142:       if msg.is_a?(Array)
    143:         args= msg.clone
    144:         msg= args.shift
    145:         args= nil if args.empty?
    146:       end
    147:       msg= ltry(msg)
    148:       msg= msg % args unless args.nil?
    149:       add_without_gloc(attribute, msg)
    150:     end

current_language()

Inherits the current language from the base record.

[Source]

         # File lib/gloc-rails.rb, line 152
    152:     def current_language
    153:       @base.current_language
    154:     end

[Validate]