Skip to content

Commit

Permalink
Extracting a method to get rid of the duplication of the image tag pa…
Browse files Browse the repository at this point in the history
…rt of the avatar
  • Loading branch information
carols10cents committed Aug 10, 2012
1 parent ab788d6 commit adebf01
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions app/decorators/author_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ def avatar
h.content_tag "div", :class => "avatar" do
if author
h.link_to(
h.image_tag(
absolute_avatar_url,
:class => "photo user-image",
:alt => "avatar"
),
avatar_image_tag,
author.url
)
else
h.image_tag(
absolute_avatar_url,
:class => "photo user-image",
:alt => "avatar"
)
avatar_image_tag
end
end
end

# Just the image tag part of the avatar markup
def avatar_image_tag
h.image_tag(
absolute_avatar_url,
:class => "photo user-image",
:alt => "avatar"
)
end

# Make sure we're using the asset path if the user's avatar is the default
# (local) avatar
def absolute_avatar_url
Expand Down

0 comments on commit adebf01

Please sign in to comment.