How do I reject the creation of an object if all of the attributes are blank?
accepts_nested_attributes_for :questions, :allow_destroy => true, :reject_if => lambda {|a| a.each.blank? }
How do I reject the creation of an object if all of the attributes are blank?
accepts_nested_attributes_for :questions, :allow_destroy => true, :reject_if => lambda {|a| a.each.blank? }
You can do like this using all? method
accepts_nested_attributes_for :questions, :allow_destroy => true, :reject_if => lambda { |attrs| attrs.all? { |k, v| v.blank?}}
Does that still reject the object if the id attribute is not blank? Do I have to test each attribute separately and exclude the id attribute in order for that to work?