Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我得到了代码
<%= f.select :wahl1, options_for_select(@berufs) %>
我在组合框中得到 id´s 或 smth#<Beruf:0x45ed8e8>而不是 @berufs 的名称
#<Beruf:0x45ed8e8>
options_for_select需要一个简单的键和值的数组或散列。然而,您正在向它传递一组模型。
options_for_select
你想要的是options_from_collection_for_select,例如:
options_from_collection_for_select
= f.select :wahl1, options_from_collection_for_select(@berufs, 'id', 'name')