如何在选择框中显示属性?

时间:2013-07-05 18:16:09

标签: ruby-on-rails

如何在下拉列表中显示每辆车的布尔活动属性? 即凯美瑞 - 活跃       吉普车 - 停用       协议 - 积极

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

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

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