私の周り掘りから、それはあなたが(すべてのフォームのために呼び出されます)RailsのFormBuilderの初期化方法を見てみるとindex
またはchild_index
のいずれかに渡すことができますように、あなたはそれにはデフォルトはありませんことを確認することができます見えます実際には上記の値をチェックします:
# rails/actionview/lib/action_view/helpers/form_helper.rb
# lines 1284 - 1297
def initialize(object_name, object, template, options)
@nested_child_index = {}
@object_name, @object, @template, @options = object_name, object, template, options
@default_options = @options ? @options.slice(:index, :namespace) : {} ### < NO DEFAULTS
if @object_name.to_s.match(/\[\]$/)
if object ||= @template.instance_variable_get("@#{Regexp.last_match.pre_match}") and object.respond_to?(:to_param)
@auto_index = object.to_param
else
raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"
end
end
@multipart = nil
@index = options[:index] || options[:child_index] ### < CHECKS FOR VALUES
end
私の知見を援助するために、上記のソースにコメントを追加しました。
参考リンク: