Max Williams wrote: > In my schema, a question has_many :answers. When the validations are > run on a question, and one of the answers is not valid, then i get > > "Answers is not valid" > > coming out of errors.full_messages. I don't want this, i'm already > testing the validity of the answers and this is an ugly and > uninformative error message. It looks like it's the message i would get > back if i was calling > > validates_associated :answers > > but i'm not, and if i *do* add this line > > validates_associated :answers, :message => "are not all valid" > > then i get "Answers are not all valid" AND "Answers is not valid". So, > i guess it's coming from somewhere else. But i can't work out where. > With logging all i can see is that it happens during validation, and it > happens *before* any other custom validations that i specify. Ie, > whatever is doing this seems to be doing it as the first step of the > validation sequence. If i take out all of my validations then it still > occurs. After doing that, the only reference to answers in the whole > class is the association: > > has_many :answers, :class_name => "MillionaireAnswer", :order => > "position", :dependent => :destroy > > The answers don't add any errors to their parent question when they are > validated, and there's nothing going on in the controller to shove > anything else in there. I could do something horrible and hacky and > remove it from the error messages before showing them on the page but > i'd rather understand what's going on. > > Anyone got any ideas? max > In case it's relevant here's my classes for questions and answers.
Hi Max, the scenario is that you are getting two error messages, one is generated (Answers are not all valid) and other one is default (Answers is not valid), and you are trying to remove the error message generated by default. Please correct me if I am wrong. Thanks Saurabh -- 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---