Rejecting a nested object if all attributes are blank

How do I reject the creation of an object if all of the attributes are

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?}}


that works, thanks!

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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs