I have the following partial (_card_brand.html.erb
), which looks like this:
<div class="payment-card">
<i class="fa fa-cc-<%= brand.downcase %> payment-icon-big text-success"></i>
</div>
That renders HTML that looks like this:
<div class="payment-card">
<i class="fa fa-cc-visa payment-icon-big text-success"></i>
</div>
The above is rendered with this:
<%= render partial: "subscriptions/card_brand", locals: { brand: current_user.card_brand } %>
What I want to do is change the class text-success
, to be either: text-warning, text-primary, text-danger, etc.
depending on if the card has brand: visa, amex, mastercard, discovery, etc.
So:
- Visa = Success
- AMEX = Warning
- Mastercard = Primary
- Discovery = Danger
Any other cards would be other classes.
How do I elegantly represent that in my view that renders the partial?