Validate presence of 2 fields


Is it possible top validate the presence of 2 field?

Maybe I am blind, but I can’t figure out how to validate based on the
presence of 2 fields.

Lon B.
AIM: spdemac


Just do validates_presence_of on each? I suspect that that’s not what
you wanted to hear, and that I didn’t understand your problem, so to
roll your own validation, you can use validates_each. Example:

validates_each(:field1, :field2) do |record, field_name, field_value|
#This block is run once for each field, so 2x in this example.
record.errors.add “is invalid” if some_test.fails?