Paul Makepeace
2012-Sep-04 18:59 UTC
Validating an association as a whole rather than per entry
I have, `Transaction.has_many :splits` and Split has an amount:integer attribute. I''d like to ensure `transaction.splits = [split1, split2, ...]` the sum of split1.amount + split2.amount + ... == 0. It seems that :before_add deals with the splits one by one whereas what I''d like is to check the array that''s being assigned (`[split1, ..]`) beforehand. Is such a thing possible? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/96ufvG0qMRwJ. For more options, visit https://groups.google.com/groups/opt_out.