I have a nested form that instantiates as this :
- 2.times { @organization.referrals.build }
- form_for @organization do |f|
= f.error_messages
- f.fields_for :referrals do |f|
Except, the nested forms are supposed to be always new and unique. Where as this form shows previously created objects as well.
So I tried to write as so..
- 2.times { @organization.referrals.build }
- form_for @organization do |f|
= f.error_messages
- f.fields_for @organization.referrals.select{|r| r.new_record? } do |f|
But now I do not see 2 blank forms, and I can not save my object because it tries to pass Organization.referral
(which is not a method) instead of Organization.referrals
.
Question 1
How do I create 2 blank forms?
Question 2
How do I get this to pass correctly ( as it does in the first example ) ?