Skip to content

Instantly share code, notes, and snippets.

@excid3
Created June 12, 2012 17:39
Show Gist options
  • Save excid3/2918955 to your computer and use it in GitHub Desktop.
Save excid3/2918955 to your computer and use it in GitHub Desktop.
.in-service {
color: #00FF00;
}
.en-route {
color: red;
}
.to-hospital {
color: blue;
}
.on-scene {
color: gray;
}
.out-of-service {
color: orange;
}
module UnitsHelper
def set_status(status)
# Converts the status (if it's not nil) to a parameter version
# "In Service" => "in-service"
status.try(:unit_status).try(:parameterize)
end
end
<td>
<div class="<%= set_status(unit.status) %>"> <!-- sets the div class to the parameter version, like <div class="in-service"> -->
<%= unit.status.try(:unit_status) %> <!-- outputs the text of the unit status, like "In Service" -->
</div>
</td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment