Helper method that determines the default error message used by Active Record. Works for both existing Rails 2.1 and Rails 2.2 with the newly introduced I18n module used for localization.
default_error_message(:blank) default_error_message(:too_short, :count => 5) default_error_message(:too_long, :count => 60)
# File lib/shoulda/active_record/helpers.rb, line 18 18: def default_error_message(key, values = {}) 19: if Object.const_defined?(:I18n) # Rails >= 2.2 20: result = I18n.translate("activerecord.errors.messages.#{key}", values) 21: if result =~ /^translation missing/ 22: I18n.translate("errors.messages.#{key}", values) 23: else 24: result 25: end 26: else # Rails <= 2.1.x 27: ::ActiveRecord::Errors.default_error_messages[key] % values[:count] 28: end 29: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.