2013-07-05 38 views
0

如何在我的下拉菜單中顯示每個車輛的布爾活動屬性? 即美瑞 - 活性 吉普車 - 停用 協議 - 活性如何在選擇框中顯示屬性?

= select("drivers_vehicle", "vehicle_id", Vehicle.accessible_by(current_ability).all.collect { |o| [o.name, o.id] })

回答

2
= select("drivers_vehicle", "vehicle_id", Vehicle.accessible_by(current_ability).all.collect { |o| ["#{o.name} - #{o.active ? 'active' : 'deactivated'}", o.id] }) 
+0

阿。對。而實際上你可能想要o.active? ? 'active':'停用' – GoGoCarl

+1

完美!謝謝! – Bruno

0
= select("drivers_vehicle", "vehicle_id", Vehicle.accessible_by(current_ability).all.collect { |o| ["#{o.name} - #{o.active}", o.id] })