# Collection\_select on controller update actions

**URL:** <https://www.ruby-forum.com/t/collection-select-on-controller-update-actions/175628>\
**Category:** Rails\
**Created:** [September 16, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/collection-select-on-controller-update-actions/175628 "2009-09-16T20:55:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tony](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@tony](https://www.ruby-forum.com/u/tony)\
**Post date:** [September 16, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/collection-select-on-controller-update-actions/175628/1 "2009-09-16T20:55:41Z")

</div>

When doing a controller update operation, missing parameters are  
treated as unchanged. This is a great convention but I’m not sure how  
to handle this when using a collection\_select.

If a user deselects all items in a the HTML select, nothing is sent on  
the update action.

For example, if 2 items are selected I get  
params[:selected\_location\_ids] == [“22”, “242”]

if no items are selected the params[:selected\_location\_ids] is not  
sent.

Is there a way to make the HTML form send an empty option when nothing  
is selected so I can know if the user deselected everything vs an  
alternate form not sending this information?

---

<div class="post-metadata">

**Author:** ![tony](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@tony](https://www.ruby-forum.com/u/tony)\
**Post date:** [September 17, 2009, 10:34am UTC](https://www.ruby-forum.com/t/collection-select-on-controller-update-actions/175628/2 "2009-09-17T10:34:01Z")

</div>

Try passing a hidden\_field\_tag with the location\_ids set to blank  
underneath the collection\_select.

ex:

\<%= hidden\_field\_tag ‘[selected\_location\_ids][]’ %\>
