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, <tt>:invalid</tt> 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 <tt>Time.now</tt> 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:ByrneJB@Harte-Lyne.ca
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
on 2013-03-06 22:33
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.