Rails 3 Validation, Multiple Fields

Have 4 fields (alpha, beta, gamma, delta), at least 1 of them must matter, i.e. not be nil / empty / empty. How can I create a check to verify this?

+4
source share
1 answer
validate :something_must_be_set def something_must_be_set unless alpha || beta || gamma || delta errors.add(:base, "Alpha, Beta, Gamma or Delta must be present.") end end 
+7
source

All Articles