Reputation: 12042
I have something like
accepts_nested_attributes_for :questions, :allow_destroy => true, :reject_if => lambda {|q| q[:body].blank?}
The problem is that if I want to update questions and they are empty they are rejected which means they won't be validated.
Is there a way to enforce that the reject only happens on create and not update?
Upvotes: 2
Views: 156
Reputation: 3283
Perhaps a check whether the :id
value is blank? If it's blank then you know that it is a create.
Upvotes: 1