I have an app I'm working on with Rails 3.2.x and Bootstrap 2. I have a view helper which returns different text based on a call's status and attributes.
def status(call)
if call.call_status == "open" && call.transfer_date > Time.zone.now + 15.minutes
"Scheduled"
elsif call.wait_return == "yes" && call.call_status == "open"
"Active/Wait and Return"
elsif call.call_status == "close"
"Closed Call"
elsif call.call_status == "cancel"
"Cancelled Call"
else
"Active"
end
end
I'd like to refactor this to where each condition's text returns a bootstrap badge with the text inside of it. I looked at the API docs for content_tag
and I think this is what I need but I'm not 100% sure on how to make this work.
Any help or refactoring advice would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire