aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorPascal Ehlert <dadark@pascal-ehlerts-macbook-pro.local>2009-02-02 22:49:28 +0100
committerMichael Koziarski <michael@koziarski.com>2009-02-06 13:26:58 +1300
commitd15d53cf810014b90827015ecd0e601176492fb7 (patch)
tree17360de26c0d809055db59953ee38199bbc348df /actionpack/lib/action_view
parentc96382a71a77505ea2f51e43bc81fdb3ac95d117 (diff)
downloadrails-d15d53cf810014b90827015ecd0e601176492fb7.tar.gz
rails-d15d53cf810014b90827015ecd0e601176492fb7.tar.bz2
rails-d15d53cf810014b90827015ecd0e601176492fb7.zip
Allowing an object to be passed explicitly to a fields_for with nested_attributes on one-to-one associations
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1849 state:committed]
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb3
1 files changed, 2 insertions, 1 deletions
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