Bruno
Bruno

Reputation: 6459

How to display to attributes in a select box?

How do I show the boolean active attribute for each Vehicle in my dropdown? i.e. camry - active jeep - deactivated accord - active

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

Upvotes: 0

Views: 31

Answers (2)

Bachan Smruty
Bachan Smruty

Reputation: 5734

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

Upvotes: 2

GoGoCarl
GoGoCarl

Reputation: 2517

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

Upvotes: 0

Related Questions