styling for true false values
Add the helper below, and you will be able to style true/false values like this:
app/helpers/application_helper.rb:
# boolean green or red
def boolean_label(value)
case value
when true
text = 'Yes'
badge_color = 'badge bg-success text-light'
when false
text = 'No'
badge_color = 'badge bg-danger text-light'
end
tag.span(text, class: badge_color)
end
your view:
= boolean_label(user.confirmed?)
Did you like this article? Did it save you some time?