Suppose I have a Person model and Address model as such:
class Address < ActiveRecord::Base
belongs_to :person
enum addresstype: {"primary" => 0, "bank" => 1}
end
class Person < ActiveRecord::Base
has_many :addresses
accepts_nested_attributes_for :addresses, allow_destroy: true
end
How do I validate the Person model for the presence of at least one primary and one bank address per person?