Rails 3: Validate combined values

Bear with me. The way the validates method in ActiveModel works is to look for a Validator.

:presence => true looks for PresenceValidator and passes the options: true to the validator’s initializer.

I think you want

validates :husband, :presence => true, :uniqueness => {:scope => :wife}

(The uniqueness validator is actually part of ActiveRecord, not ActiveModel. It’s really interesting how the developers set this up. It’s quite elegant.)

Leave a Comment