Select does not generate selected

Hi,

I have this code:
<%= debug @deposit.to_user_id %>
<%= select(“deposit”, “to_user_id”, User.find_all.collect {|u|
[ u.fullname, u.id.to_s ] }, {:prompt => ‘Select a user’, :selected =>
@deposit.to_user_id} ) %>

It generates this:
— 2
Leon B.

Gijs Everaard

Why doesn’t it generate the prompt and the selected?

With kind regards,
Leon B.

Anyone? If I change the to_user_id in user_id it works. But that
requires a change in the database and makes the whole just less
readable. Especially because there’s another field called
from_user_id.

Maybe there’s anoyher way of achieving the same?

Ahh… got it. This worked:
<%= collection_select(“deposit”, “to_user_id”, User.find_all, “id”,
“fullname”, :selected => “to_user_id”) %>

But now :prompt does not work anymore…
<%= collection_select(“deposit”, “to_user_id”, User.find_all, “id”,
“fullname”, :selected => “to_user_id”, :prompt => “This is a test”)
%>

Ah…
This works:
<%= collection_select(“deposit”, “to_user_id”, User.find_all, “id”,
“fullname”, {:prompt => ‘Dit is een test’} ) %>

if to_user_id would not be “0”. It’s an integer and probably it’s zero
to default. Can I change this behaviour? Else the selectlist won’t
work. And setting it to ‘’ before each selectlist seems like a crappy
solution.

Ah got it… Yes again…
table.column :to_user_id, :integer, :default => nil does it