Hello,
I have a model called Sample that has many Treatments. A Treatment can have many Results.
I want to reject the creation of a Treatment if all its fields are blank and if all the fields of each of its nested Results are blank.
I have this in the Sample model:
accepts_nested_attributes_for :treatments, :allow_destroy => true, :reject_if => proc { |attributes| attributes['treatmenttype'].blank? && attributes['author'].blank? && attributes['results_attributes'].blank? }
This part: attributes['results_attributes'].blank?
only makes it reject the Treatment if there are no Results, but how can I write the conditions so that it will reject the creation of a Treatment if all the attirubtes of each Result are blank? Right now it creates the Treatment if the Result exists, regardless of whether all its fields are blank.