Notifications
You’re not receiving notifications from this thread.
User Badges Features
I might be able to squeeze it in sometime. It's a lot simpler than you might think. :)
# app/helpers/user_helper.rb
def user_badges(user)
badges = []
badges << sub_badge(user)
badges << content_tag(:span, "Mod", class: "label label-primary") if user.moderator?
badges << content_tag(:span, "Staff", class: "label label-success") if user.staff?
badges.join(" ").html_safe
end
def sub_badge(user)
case user.charges_count
when 1..2
content_tag :span, fa_icon("diamond"), class: "label label-default", data: {toggle: :tooltip}, title: "1-Month Subscriber"
when 3..5
content_tag :span, fa_icon("diamond"), class: "label label-warning", data: {toggle: :tooltip}, title: "3-Month Subscriber"
when 6..11
content_tag :span, fa_icon("diamond"), class: "label label-primary", data: {toggle: :tooltip}, title: "6-Month Subscriber"
when 12..23
content_tag :span, fa_icon("diamond"), class: "label label-danger", data: {toggle: :tooltip}, title: "1-Year Subscriber"
when 24..1000
content_tag :span, fa_icon("diamond"), class: "label label-purple", data: {toggle: :tooltip}, title: "2-Year Subscriber"
end
end
At some point I might refactor this into a badge model and add rules and things into that if I expand the badging system past the basics. The sub_badge
method needs some refactoring anyways. I also have a little bug that if you paid annually, it doesn't calculate your badge right, so the number of charges isn't a perfect count of a user's subscription length.
Maybe the episode would be good talking about refactoring this?