nested attribute relationship never renders in form

Hey all,

I tried following this railscasts:

But there is one significant difference from what that does and what I
am trying to do. That builds a relationship to one object. In my form,
i have a list of objects and want to build relationship for each item
in list.

class Rule < ActiveRecord::Base
  has_many :notification_emails, :dependent => :destroy
  accepts_nested_attributes_for :notification_emails, :reject_if =>
lambda { |notification| notification[:email].blank? }

class NotificationEmail < ActiveRecord::Base
  belongs_to :rule


def rules_config
      @rules = rules.flatten
      @rules.each { |a| }

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


    = form_for "rule[]", '/home/save_rules/' +, :remote
=> true, :class => 'ajaxCall' do |f|
      %table.scrollTable{:cellspacing => "0", :width =>
"740px", :style => "border-collapse: collapse; border-spacing: 0;"}
            %th Rules
            %th Enable
            %th Email
            %th Notification Emails
          - for rule in @rules
              %td= check_box_tag "enabled_ids[]",
              %td= f.text_field :email, :value =>, :index
                - f.fields_for :notification_emails do |notification|
                  = notification.text_area :email, :rows => 1

Basically I have a list of rules that a user can edit and then update
in this form. But each rule can have many notification emails and
since I built an association in controller, I expect this cell to
contain a text area field that links the relatonship. But the text
area field never displays.

thanks for response

Depending on which Rails version you’re using, you might need to change:

  • f.fields_for :notification_emails do |notification|


= f.fields_for :notification_emails do |notification|

(notice the = change)