Permalink
Browse files

Adding and hiding friends is working again (changed from link to butt…

…on).
  • Loading branch information...
1 parent e1cffc1 commit c66ae5f3fcf36d15dbad0d986a01f389ec3d3e44 Jen-Mei Wu committed Apr 22, 2011
Showing with 5 additions and 3 deletions.
  1. +4 −2 app/helpers/application_helper.rb
  2. +1 −1 app/models/user.rb
@@ -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
View
@@ -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

0 comments on commit c66ae5f

Please sign in to comment.