Forum: Ruby on Rails Collection_select does not return empty array if no options

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
79226fa87c8b3396250947ae9abf38b3?d=identicon&s=25 dotjake (Guest)
on 2007-06-27 22:15
(Received via mailing list)

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

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

This topic is locked and can not be replied to.