aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-06 19:25:03 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-06 19:25:03 -0300
commit693b333920fc2f5b74f157d46d531cd97b692006 (patch)
treebba09ddab8113aadbf28c4168b2b0747139652cd /actionview/lib
parentd5f80655f9d285cf569ec28e741bbc4bd16e6599 (diff)
parenta813fa09a86ec522b43f16d137bd99e0a43985f5 (diff)
downloadrails-693b333920fc2f5b74f157d46d531cd97b692006.tar.gz
rails-693b333920fc2f5b74f157d46d531cd97b692006.tar.bz2
rails-693b333920fc2f5b74f157d46d531cd97b692006.zip
Merge pull request #19661 from Azdaroth/fields-for-child-index-lambda
Accept lambda as child_index option in #fields_for method
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index 891cc53765..ece117b547 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -1928,7 +1928,11 @@ module ActionView
explicit_child_index = options[:child_index]
output = ActiveSupport::SafeBuffer.new
association.each do |child|
- options[:child_index] = nested_child_index(name) unless explicit_child_index
+ if explicit_child_index
+ options[:child_index] = explicit_child_index.call if explicit_child_index.respond_to?(:call)
+ else
+ options[:child_index] = nested_child_index(name)
+ end
output << fields_for_nested_model("#{name}[#{options[:child_index]}]", child, options, block)
end
output