Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Show the nickname of user who likes the gist #11

Merged
merged 1 commit into from

2 participants

@tototoshi

No description provided.

@seratch seratch merged commit 67863d2 into seratch:develop
@seratch seratch was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 8, 2013
  1. @tototoshi
This page is out of date. Refresh to see the latest.
View
4 app/helpers/application_helper.rb
@@ -33,8 +33,8 @@ def find_my_favorite(gist)
end
end
- def favorite_count(gist)
- gist.favorites.try(:size)
+ def favorite_users(gist)
+ gist.favorites.map { |f| f.user }
end
end
View
5 app/views/gists/show.html.erb
@@ -6,9 +6,8 @@
<% if @gist.is_public %>
<i class="icon-pencil"></i>&nbsp;<%= @gist.title %>
<span class="pull-right">
- <% favorites = favorite_count(@gist) %>
- <% if favorites > 0 %>
- <% (1..favorites).each do %><i class="icon-heart"></i><% end %>
+ <% favorite_users(@gist).each do |user| %>
+ <i class="icon-heart" rel="tooltip" title="<%= user.nickname %>"></i>
<% end %>
</span>
<% else %>
View
4 spec/helpers/application_helper_spec.rb
@@ -28,8 +28,8 @@ def current_user
it 'get something from #recent_gists' do
recent_gists.should_not be_nil
end
- it 'get something from #favorite_count' do
- favorite_count(gist).should_not be_nil
+ it 'get something from #favorite_users' do
+ favorite_users(gist).should_not be_nil
end
end
Something went wrong with that request. Please try again.