# Noob collection\_select question

**URL:** <https://www.ruby-forum.com/t/noob-collection-select-question/170493>\
**Category:** Rails\
**Created:** [June 18, 2009, 5:25am UTC](https://www.ruby-forum.com/t/noob-collection-select-question/170493 "2009-06-18T05:25:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [June 18, 2009, 5:25am UTC](https://www.ruby-forum.com/t/noob-collection-select-question/170493/1 "2009-06-18T05:25:18Z")

</div>

Hi, I have a question about the collection\_select helper and how it  
saves using the update\_attributes command. If I have a form\_for using a  
model instance such as @person and have elements inside it like:

\<%= f.text\_field :lastName %\>

and then want to include a selection drop down that has zip codes that  
are sourced from another table such as:

\<%= collection\_select @person, :zipCode, @allZipCodes, :zipCode,  
:zipCode %\>

when I use the controller to update these fields using the command:

@person = People.find(params[:id])  
@person.update\_attributes(params[:person])

how do I get the collection\_select to save its value automatically? If  
I do the above example, lastName is saved but what is selected in the  
drop-down is not. Am I using the wrong syntax? I haven’t been able to  
get f.collection\_select to work, so I’m not sure where to go from here  
(besides setting that attribute manually – hopefully not!!!).

If you could help I’d definitely appreciate it. Thanks!

---

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [June 18, 2009, 6:06am UTC](https://www.ruby-forum.com/t/noob-collection-select-question/170493/2 "2009-06-18T06:06:40Z")

</div>

Finally found the answer on google. Thanks anyways!

---

<div class="post-metadata">

**Author:** ![spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@spencer](https://www.ruby-forum.com/u/spencer)\
**Post date:** [September 15, 2009, 11:31am UTC](https://www.ruby-forum.com/t/noob-collection-select-question/170493/3 "2009-09-15T11:31:45Z")

</div>

Spencer R. wrote:

> Finally found the answer on google. Thanks anyways!

Hey Spencer,

could you share with me how you managed to save the update to the table?

Cheers,

docgecko
