All,
When using validates_associated to cause cascading validation from my
parent AR class into it''s children, by default a "_____ is
invalid"
message is added to the errors collection for the parent for each child
object that isn''t valid.
I don''t want to display these messages, since I am generating new
messages to stand in their place.
I am using the standard scaffolding error reporting scheme
(errorExplanation div and fieldWithErrors around each field).
I can suppress these messages by setting :message => '''' or
:message =>
nil on the validates_associated, but what I really want to do is to
remove the errors from the errors collection that are associated with
the "is invalid" messages.
I tried this:
#Get rid of all of the annoying "is invalid" error messages and
generate
unique errors for the class codes
old_errors = @artisan_quote_input.errors.clone
@artisan_quote_input.errors.clear
old_errors.each_full do |msg|
@artisan_quote_input.errors.add_to_base(msg) unless msg =~ /is
invalid/ || @artisan_quote_input.errors.full_messages.include?(msg)
end
But then several of my fields no longer show up with red borders in my
form.
Anybody have any experience with manipulating the ActiveRecord::Errors
object in this way?
Thanks,
Wes
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---