think you just need 'validates_associated' http://railsmanual.org/module/ActiveRecord::Validations::ClassMethods?method=validates_associated
On Sat, Apr 19, 2008 at 8:49 AM, tommy <[EMAIL PROTECTED]> wrote: > > I have a form that has a user model and an array of todo models. I'm > trying to figure out how to do the validation with rails correctly. > > the user part is no problem, but for the array of todo models, the > errors aren't being displayed back. > > in the Todo validate method, I do some logic to see if certain columns > are defined and an errors.add_to_base call. > > I know each validate works in the model because i did a debugger and > 'p errors' which shows the error for the corresponding todo model. > > How does Rails handle errors for multiple objects of the same model? > > In the view, i tried error_messages_for :todo and :todos > > In the controller, i process the todo each separately. > > The only way i can get it to work is to do: > todo.validate > raise "error for todo" if todo.errors > > This is a less than ideal solution since it'll only show one error at > a time. > > Any ideas? > > > --~--~---------~--~----~------------~-------~--~----~ SD Ruby mailing list sdruby@googlegroups.com http://groups.google.com/group/sdruby -~----------~----~----~----~------~----~------~--~---