options_for_select selected value not working

ruby-on-rails

Solution

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

Problem

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 ```

Original source