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-boovWovfBzKWxEb2tNKyrg@public.gmane.org
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
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.