From d15d53cf810014b90827015ecd0e601176492fb7 Mon Sep 17 00:00:00 2001 From: Pascal Ehlert Date: Mon, 2 Feb 2009 22:49:28 +0100 Subject: Allowing an object to be passed explicitly to a fields_for with nested_attributes on one-to-one associations Signed-off-by: Michael Koziarski [#1849 state:committed] --- actionpack/lib/action_view/helpers/form_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 2ac2427884..0651f75cfb 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -971,7 +971,8 @@ module ActionView @template.fields_for(child_name, child, *args, &block) end.join else - @template.fields_for(name, association, *args, &block) + object = args.first.respond_to?(:new_record?) ? args.first : association + @template.fields_for(name, object, *args, &block) end end -- cgit v1.2.3