There's a bug with accepts_nested_attributes_for. Meaning you have to be a little more devious when it comes to validations in the parent model.
You could use an :after_save callback in each of your nested models to check if it's the last one. But if there's many nested associations where you want to ensure at least one, this isn't very DRY.
This is however a valid workaround for the linked bug:
class Whatever < ActiveRecord::Base
:has_many => :association_a
:has_many => :association_b
def ensure_minimum_associations
bad_associations = [:association_a, :association_b].
select{|assoc| self.send(assoc).all?{|a| a.marked_for_destruction?}}
unless bad_associations.empty?
bad_associations.each do |association|
errors.add_to_base "Each #{self.class.name.downcase} must retain at least one #{association}"
end
return false
end
end
end