You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
asciinema.org/app/decorators/user_decorator.rb

32 lines
683 B
Ruby

class UserDecorator < ApplicationDecorator
decorates :user
def asciicasts_count
model && model.asciicasts.count
end
def avatar_img(options = {})
klass = options[:class] || "avatar"
title = options[:title] || user && "~#{user.nickname}"
h.image_tag user && user.avatar_url || default_avatar_url,
:title => title, :alt => title, :class => klass
end
def default_avatar_url
h.image_path "default_avatar.png"
end
def avatar_profile_link(options = {})
options = { :class => '' }.merge(options)
if user
h.link_to h.profile_path(user) do
avatar_img(options)
end
else
avatar_img(options)
end
end
end