On 4 April 2011 17:57, John W. <[email protected]> wrote: > Colin Law wrote in post #990706: >> On 3 April 2011 19:36, John W. <[email protected]> wrote: >>> I have a scenario where I have to prevent objects from saving to the >>> database if they have a certain value and I want to come up with the >>> optimal way to achieve that. >> >> You could use a validation. That would be the normal method. Then >> you can just call save and only the valid ones will actually be saved. >> >> Colin > > Validation failure would make all 20 records and the parent object save > fail in totality. I'm trying to have everything save minus the nested > objects with a certain field value of "i". All other nested objects > with other values save fine.
I am not sure you made it entirely clear that you were using accepts_nested_attributes_for, but perhaps in retrospect it was fairly obvious. In which case you are right and Garrett's suggestions may be the way to go. Colin -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

