2013-05-14 27 views
0

目前,如果您致電@team.user_ids,它將返回"1,3,7"而不是[1,3,7]。我需要它是因爲其他原因,但它打破了前端collection_select。我已經測試過,並且它對數組工作正常,所以現在剩下的唯一步驟就是手動選擇要選擇的項目,因爲我無法使用Rails的默認方式。如何控制:選爲collection_select?

= f.collection_select :user_ids, @company.users, :id, :username, 
    { :include_blank => true }, { :multiple => true, :class => "chzn-select" } 

我該怎麼做呢?謝謝!

回答

0

我解決了它加入:selected => @team.users.map(&:id)