update a list of model instances and their associations

I have been unable to figure out how to update a list of model instances and their associations and I have looked in the documentation, which doesnt give an example of what I am trying to do:

I would assume this is a common task though.

I have an established association:

class AlertRule < ActiveRecord::Base

    has_many :notification_emails, :dependent => :destroy     accepts_nested_attributes_for :notification_emails end

class NotificationEmail < ActiveRecord::Base   belongs_to :alert_rule end

Controller:

def alerts_config

      //more code       @alert_rules = alert_rules.flatten       @alert_rules.each { |a| a.notification_emails.build }

      render :partial => 'home/alerts_config', :layout => false

View:

= form_tag '/home/save_alerts_config/' + @unit.id.to_s, :remote => true, :class => 'ajaxForm' do       %table.scrollTable{:cellspacing => "0", :width => "740px", :style => "border-collapse: collapse; border-spacing: 0;"}         %thead.fixedHeader           %tr             %th Alerts             %th Enable             %th Primary Email             %th Notification Emails             %th         %tbody.scrollContent           - for rule in @alert_rules             = fields_for :alert_rules, rule do |f|               %tr                 %td= rule.alert_code.name                 %td= check_box_tag "enabled_ids", rule.id                 %td= f.text_field :email, :value => rule.email, :index => rule.id                 %td.fields                   = f.fields_for :notification_emails do | notification_builder|                     = notification_builder.text_field :email