Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

collection_select doesn't honour :index option to fields_for

#145

If I do

fields_for :post, @post, :index => 1 do |f|
  f.collection_select(:author_name, @posts, :author_name, :author_name)
end

I get

<select name="post[author_name]" ... >

Instead of the expected

<select name="post[1][author_name]" ... >

Without specifying index, it works correctly, i.e.

fields_for 'post[]', @post do |f|

does generate the correct <select name="post[1][author_name]"

The other helpers (text_field, checkbox etc) do work correctly with the :input option.

Reported by David Röthlisberger · May 8th, 2008 @ 05:31 PM

State: duplicate
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. David Röthlisberger
    David Röthlisberger

    This is on edge rails.

    See the test cases in attached 145-001.patch:

    the first test (test_collection_select_under_fields_for_with_collection) passes;

    the second (test_collection_select_under_fields_for_with_collection) fails.

    May 8th, 2008 @ 05:35 PM

  2. David Röthlisberger
    David Röthlisberger

    In the previous comment, the second test should be named "test_collection_select_under_fields_for_with_collection_and_index".

    May 8th, 2008 @ 05:37 PM

  3. Pratik
    Pratik
    • State changed from new to incomplete
    • Tag set to actionpack, bug

    July 14th, 2008 @ 04:33 AM

  4. Pratik
    Pratik
    • State changed from incomplete to duplicate

    July 14th, 2008 @ 04:33 AM

  5. bingbing