# Collection\_select does not return empty array if no options

**URL:** <https://www.ruby-forum.com/t/collection-select-does-not-return-empty-array-if-no-options/107966>\
**Category:** Rails\
**Created:** [June 27, 2007, 10:15pm UTC](https://www.ruby-forum.com/t/collection-select-does-not-return-empty-array-if-no-options/107966 "2007-06-27T22:15:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotjake](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c67d28/32.png) [@dotjake](https://www.ruby-forum.com/u/dotjake)\
**Post date:** [June 27, 2007, 10:15pm UTC](https://www.ruby-forum.com/t/collection-select-does-not-return-empty-array-if-no-options/107966/1 "2007-06-27T22:15:54Z")

</div>

Hello,

I have two separate category collection\_selects for two separate  
models each with a habtm relationship to categories. With the update  
form for one model, de-selecting all of the options submits a  
parameter such as category\_ids =\> [""]. In the other, de-selecting the  
options returns no parameter, and as a result the join table is not  
updated.

The collection\_selects look like this:

\<%= form.collection\_select(:category\_ids, @categories, :id, :name, {},  
{:multiple =\> true, :size =\> 5}) %\>

I can overcome the problem by adding :include\_blank =\> true to the  
options, but this is not an intuitive solution and it is absolutely  
unclear to me why this problem would occur in one model and not  
another. The only difference between the forms is that the one which  
works properly, returning an empty array, is submitted via  
remote\_form\_for, not form\_for.

Thanks in advance

Jake
