# Collection\_select with an index

**URL:** <https://www.ruby-forum.com/t/collection-select-with-an-index/135637>\
**Category:** Rails\
**Created:** [April 23, 2008, 8:22pm UTC](https://www.ruby-forum.com/t/collection-select-with-an-index/135637 "2008-04-23T20:22:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakob\_Lenfers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@Jakob\_Lenfers](https://www.ruby-forum.com/u/Jakob_Lenfers)\
**Post date:** [April 23, 2008, 8:22pm UTC](https://www.ruby-forum.com/t/collection-select-with-an-index/135637/1 "2008-04-23T20:22:45Z")

</div>

Hi,

I’m new to Rails, this is my first try, so be gentle, I tried to google  
but could solve my problem. 🙂

I’m trying to use the index-option of, for example, the text\_field in a  
collection\_select. I found out that collection\_select expects the index  
in the html\_options instead of the options as in text\_field. I found a  
similar problem  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/b3ccd87b74c6ab9b/bf6d5440d0ffefe8](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/b3ccd87b74c6ab9b/bf6d5440d0ffefe8),  
but it had no effect on my output. ATM I’m using:

line\_f.collection\_select :char\_id, @chars, :id, :firstname, :prompt =\>  
“Choose character”, “index” =\> 1

But the html output remains as follows:

\<option […]

I expected something like ‘id=“line\_1\_char\_id” name=“line[1][char\_id]”’.  
Any idea what I’m doing wrong?

TIA, Jakob
