0
我已經在我的表單中選擇了所有組。所以我循環遍歷所有可用的組。在編輯時,使用選擇表單助手
但是;當我嘗試編輯客戶端時,選擇框不會將選定內容添加到我選擇的組中。很可能是因爲它的循環。我如何選擇正確的一個?
<%= f.select(:group_id, options_for_select(@usersGroups.collect{ |u| [u.name, u.id] }), :prompt => "Kies een groep") %>
你也可以做到像<%= f.select(:GROUP_ID,options_from_collection_for_select(@ usersGroups.all ,name,id),:prompt =>「Kies een groep」)%> –