Noob collection_select question

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])

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!

Finally found the answer on google. Thanks anyways!

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?



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs