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| a.notification_emails.build }

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


= form_for "rule[]", '/home/save_rules/' + @unit.id.to_s, :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= rule.rule_code.name
%td= check_box_tag "enabled_ids[]", rule.id
%td= f.text_field :email, :value => rule.email, :index
=> rule.id
- 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

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
grouprubyonrails-talk @
postedMar 16, '12 at 9:02p
activeMar 18, '12 at 3:45p



site design / logo © 2021 Grokbase