# Question regarding collection\_select

**URL:** <https://www.ruby-forum.com/t/question-regarding-collection-select/130301>\
**Category:** Rails\
**Created:** [February 27, 2008, 6:53am UTC](https://www.ruby-forum.com/t/question-regarding-collection-select/130301 "2008-02-27T06:53:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tallp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e57/32.png) [@tallp](https://www.ruby-forum.com/u/tallp)\
**Post date:** [February 27, 2008, 6:53am UTC](https://www.ruby-forum.com/t/question-regarding-collection-select/130301/1 "2008-02-27T06:53:04Z")

</div>

Hello:

I have two models:

1. Users
2. Categories

I have successfully used this helper in the “new” and “edit” views:

\<%= collection\_select(:user, :cat\_id, @categories, :id, :name) %\>

This gets me a nice drop down list with all of my categories. But when  
I look at the “show” or “index” views, the cat\_id field simply lists  
the id: of the category (i.e. a 1 or 2 or 3) rather than the nice  
category name that is listed in the drop box (gold,silver,bronze).

I understand why this is happening, but I would like the code in that  
I would use in my “index” or “show” views to get the category name  
versus ID.

Right now the code is simply \<%=h user.cat\_id %\> which gives me the  
number, not the name.

Thanks in advance for the help.

-Tallp
