I have a form for projectuser data, but when I edit the projectuser, the selected projectuser stays empty, what is going wrong? This is the code:
= f.select :user_id, options_for_select(@users.map{ |u| [u.full_name, u.id] }, selected: @projectuser.full_name), include_blank: true
The documentation states:
(...)
options_for_select(container, selected = nil) public
(...)
(million examples)
So you shouldn't pass selected: something
, but just something
. Also, this something needs to be selected value, not text:
= f.select :user_id, options_for_select(@users.pluck(:name, :id), @projectuser.id), include_blank: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With