Skip to content

Commit

Permalink
Added me_ify helper and added activated check.
Browse files Browse the repository at this point in the history
  • Loading branch information
aclimatt committed Apr 10, 2010
1 parent 05c40bf commit 5fe741a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ def q(s)
"\"#{s}\""
end

def me_ify(user)
if user == current_user
"me"
else
user.name
end
end
end
12 changes: 8 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ class User < ActiveRecord::Base
has_many :friendships
has_many :friends, :through => :friendships

def name(current_user="")
if self == current_user
"me"
elsif first_name
attr_protected :activated

def active?
activated
end

def name
if first_name
first_name.to_s + " " + last_name.to_s
else
email
Expand Down
4 changes: 2 additions & 2 deletions app/views/shares/_share_listing.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

<span class="username">
<% submitter = share_listing.link.submitter %>
<%= link_to submitter.name(current_user), user_path(submitter), :class => "light_link" %>
<%= link_to me_ify(submitter), user_path(submitter), :class => "light_link" %>
</span>

<%= time_ago_in_words(share_listing.submitted_time) %> ago

with

<%= share_listing.other_recipients.collect {|r| link_to r.name(current_user), user_path(r), :class => "light_link"}.to_sentence %>
<%= share_listing.other_recipients.collect {|r| link_to me_ify(r), user_path(r), :class => "light_link"}.to_sentence %>
</div>

</div>
Expand Down

0 comments on commit 5fe741a

Please sign in to comment.