Skip to content

Commit

Permalink
Adding and hiding friends is working again (changed from link to butt…
Browse files Browse the repository at this point in the history
…on).
  • Loading branch information
Jen-Mei Wu committed Apr 22, 2011
1 parent e1cffc1 commit c66ae5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -24,9 +24,11 @@ def link_to_friendship_action( user )
return "<span class='you'>this is you!</span>" if user == current_user
friend = current_user.friendship_for(user)
if friend
link_to 'hide friend', friend, :method => :delete, :confirm => "Are you sure?", :class => 'button small'
# link_to 'hide friend', friend, :method => :delete, :confirm => "Are you sure?", :class => 'button small'
button_to 'hide friend', {:controller => 'friendships', :action => "destroy", :id => friend.id}, :method => :delete, :confirm => "Are you sure?", :class => 'button small'
else
link_to 'add friend', friendships_path(:friend_id => user.id), :method => :post, :class => 'button small'
# link_to 'add friend', friendships_path(:friend_id => user.id), :method => :post, :class => 'button small'
button_to 'add friend', {:controller => 'friendships', :action => 'create', :friend_id => user.id}, :method => :post, :class => 'button small'
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -179,7 +179,7 @@ def friendship_for( user )
end

def friendship_to( user_id )
friendships.create(:friend_id => user_id)
friendships.create!(:friend_id => user_id)
friend = User.find_by_id( user_id )
deliver_friendship_notification!( friend )
end
Expand Down

0 comments on commit c66ae5f

Please sign in to comment.