I read this in the api:
# Adds +message+ to the error messages on +attribute+. More than
one error can be added to the same
# +attribute+.
# If no +message+ is supplied, :invalid is assumed.
#
# If +message+ is a symbol, it will be translated using the
appropriate scope (see +translate_error+).
# If +message+ is a proc, it will be called, allowing for things
like Time.now to be used within an error.
def add(attribute, message = nil, options = {})
message = normalize_message(attribute, message, options)
if options[:strict]
raise ActiveModel::StrictValidationFailed,
full_message(attribute, message)
end
self[attribute] << message
end
Now, other than the fact that I cannot seem to locate any method in
Rails called translate_error this bit of code does this to the symbol
that I pass it:
errors.add( :base, :dbms_constraint_violation_unique )
→
translation missing:
en.activerecord.errors.models.currency.attributes.base.dbms_constraint_violation_unique
Is there a way to turn off name spacing for this automatic
translation? This bit of code is likely to be used in more than one
model and I do not relish creating a nested nightmare of duplicated
error message translations for each.
–
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:[email protected]
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3