ryanb/nested_form

reject_if if 2 attributes are blank

Rubioli opened this issue · 2 comments

In my application I am Rejecting nested form if my sort_order attribute is blank.

reject_if: proc { |attributes| attributes['sort_order'].blank? }

How can I make is so I can reject only IF when Both sort_order AND title is blank?

Thanks in advanced!

This is easy. Your proc returns a boolean value if the entry should be rejected. So for both fields it could look like this:

reject_if: proc { |attributes| attributes['sort_order'].blank? && attributes['title'].blank? }

Great Thanks