在我的rails 4 app中,我正在使用
`accepts_nested_attributes_for :application, reject_if: proc { |attributes| attributes['uni_id'].blank? }`
但现在我需要检查它有多种选择。我想要的伪代码是这样的
accepts_nested_attributes_for :application, reject_if: proc {
(attributes['uni_id'].blank? and attributes['duration'].blank?) OR (attributes['uni_id'].blank? and attributes['semester'].blank?)
}
即,拒绝(attributes['uni_id'].blank? and attributes['duration'].blank?) OR (attributes['uni_id'].blank? and attributes['semester'].blank?)
希望可能有一些简单的解决方案。
答案 0 :(得分:0)
这对我有用
accepts_nested_attributes_for :application, reject_if: proc { |attributes|
(attributes['uni_id'].blank? && attributes['duration'].blank?) || (attributes['uni_id'].blank? && attributes['semester'].blank?)
}