# Select ... :index =\> nil is not working

**URL:** <https://www.ruby-forum.com/t/select-index-nil-is-not-working/143488>\
**Category:** Rails\
**Created:** [July 19, 2008, 7:16am UTC](https://www.ruby-forum.com/t/select-index-nil-is-not-working/143488 "2008-07-19T07:16:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuaib85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shuaib85](https://www.ruby-forum.com/u/shuaib85)\
**Post date:** [July 19, 2008, 7:16am UTC](https://www.ruby-forum.com/t/select-index-nil-is-not-working/143488/1 "2008-07-19T07:16:12Z")

</div>

Dear all

I have been trying to get this piece of code working  
[http://pastie.org/236978](http://pastie.org/236978)

 \<% fields\_for "daleel[categories\_attributes][]", category do | category\_form| %\> 

category: \<%= category\_form.select "category\_id", @categories, :prompt =\> "category", :index =\> nil %\>

```
        <% if category.new_record? %>
            <%= link_to_function "remove", "$

```

(this).up(‘.task’).remove()" %\>  
\<% else %\>  
\<%= link\_to\_function “remove”,  
“category\_for\_destroy(this)” %\>  
\<%= category\_form.hidden\_field :id, :index =\> nil %\>  
\<%= category\_form.hidden\_field :should\_destroy, :index  
=\> nil, :class =\> ‘should\_destroy’ %\>  
\<% end %\>

  
\<% end %\>

The problem is this

the select statement should hide the id however, it does not work for  
select and it works for the hidden field. I was trying hard to get it  
working in the past two days. I tried to put :index =\> nil in  
the :options and :html\_options and the same problem did not get  
solved

this concept was gotten from [#75 Complex Forms Part 3 - RailsCasts](http://railscasts.com/episodes/75)

Thanks in advance

any idea

---

<div class="post-metadata">

**Author:** ![shuaib85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shuaib85](https://www.ruby-forum.com/u/shuaib85)\
**Post date:** [July 19, 2008, 1:20pm UTC](https://www.ruby-forum.com/t/select-index-nil-is-not-working/143488/2 "2008-07-19T13:20:44Z")

</div>

On Jul 19, 6:15 am, Shuaib85 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The problem is this
> 
> the select statement should hide the id however, it does not work for  
> select and it works for the hidden field. I was trying hard to get it  
> working in the past two days. I tried to put :index =\> nil in  
> the :options and :html\_options and the same problem did not get  
> solved
> 
> this concept was gotten fromhttp://railscasts.com/episodes/75

Did you see the note at the bottom of that episode:

“The code for this screencast isn’t the greatest, it requires  
the :index option for the fields and does not work well in Rails 2.  
Instead I recommend going with the approach I show in Advanced Rails  
Recipes”

Fred
