Index: actionpack/test/template/date_helper_test.rb
===================================================================
--- actionpack/test/template/date_helper_test.rb (revision 8440)
+++ actionpack/test/template/date_helper_test.rb (working copy)
@@ -17,6 +17,13 @@
'123'
end
end
+
+ NewPost = Struct.new("Post", :id, :written_on, :updated_at)
+ NewPost.class_eval do
+ def to_param
+ ''
+ end
+ end
end
def test_distance_in_words
@@ -885,7 +892,26 @@
assert_equal expected, date_select("post[]", "written_on")
end
+
+ def test_date_select_with_auto_index_when_id_is_nil
+ @post = NewPost.new
+ @post.written_on = Date.new(2004, 6, 15)
+ expected = %{\n"
+
+ expected << %{\n"
+
+ expected << %{\n"
+
+ assert_equal expected, date_select("post[]", "written_on")
+ end
+
def test_date_select_with_different_order
@post = Post.new
@post.written_on = Date.new(2004, 6, 15)
Index: actionpack/lib/action_view/helpers/date_helper.rb
===================================================================
--- actionpack/lib/action_view/helpers/date_helper.rb (revision 8440)
+++ actionpack/lib/action_view/helpers/date_helper.rb (working copy)
@@ -645,7 +645,7 @@
prefix = "#{@object_name}"
if options[:index]
prefix << "[#{options[:index]}]"
- elsif @auto_index
+ elsif defined?(@auto_index)
prefix << "[#{@auto_index}]"
end
options.merge(:prefix => "#{prefix}[#{@method_name}(#{position}i)]")