views:

14

answers:

1

I have an Object where the object has a nested form of which can be duplicated as needed.

To accomplish this I am using :

- 2.times { @organization.referrals.build }
- form_for @organization do |f|
  = f.error_messages
  - f.fields_for :referrals do |qf|
    = render :partial => 'referral_fields', :locals => {:qf => qf}

Now I have two blank referrals for them to fill out. But I do not want the user to see the older created referrals. How do I keep the nested model form, but dissalow the end user from seeing the previously created objects?

+1  A: 

Something like this should work...

f.fields_for @organization.referrals.select{|r| r.new_record?} do |qf|
njorden
This knocks out my 2.times method. I wonder if there's something that still allows me to have multiple extra duplicates of an empty form.
Trip