Hi all,
Have a nested form, the relationship is like so
class Inspection < ActiveRecord::Base
has_many :inspection_components
accepts_nested_attributes_for :inspection_components
class InspectionComponent < ActiveRecord::Base
belongs_to :inspection
I have a custom validate method in Inspection which depends on attributes entered for InspectionComponent. How can I validate - InspectionComponent attributes are not saved or available in validation for Inspection.
Thanks!
EDIT: To make things a bit more clear, here's an example of what I'm trying to do.
Inspection has an attribute status. InspectionComponent also has an attribute status.
The Inspection edit form has nested InspectionComponents and one can update each model's status' on this form. @inspection.status should only be able to be marked 'complete' if all @inspection_component.status == 'complete'.
Therefore, when validating @inspection, I must be able to see what the user entered for @inspection_component.status.
Obviously I have access to the params of both instances in the controller however in the model, where validation should occur, I don't see a way of making this happen.
Hopefully that is clear, thanks.