diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4cc173a..8085798 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -24,9 +24,11 @@ def link_to_friendship_action( user ) return "this is you!" 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 diff --git a/app/models/user.rb b/app/models/user.rb index a295615..7e11adf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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