collection_select default value?

I'm having some confusion with collection_select(). I am using two of them on my form:

<%= collection_select(:user, :id, @users, :id, :login) %> <%= collection_select(:department, :id, @depts, :id, :name, {}, :multiple=>"multiple") %>

If I submit the page without selecting a department in the multiselect box, I will get a nil object. This is what I want.

If I submit the page without selecting a user, I do not get a nil user object. It is populated with the first item in the select box. This is not what I want. I want to detect that a user has not selected a name from the list.

Why is the first collection_select() returning a value when the user has not selected an item?


Gary H.

You have two options for this: 1) <%= collection_select(:user, :id, @users, :id, :login, {:include_blank => true}) %> to show a blank option OR 2) <%= collection_select(:user, :id, @users, :id, :login, {:promt => 'Select a user'}) %> to show a default text

Hope this helps