I'm attempting to build a proper RESTful approach at removing a friend while looking at their profile page. I've used this Railscast episode as the basis for my self referential Friendship model, but his approach differs in that he has a page listing all the friendships, with a delete button next to each one. Since he's already iterating through friendships, he has the friendship entry ID handy and can pass it into the delete link just fine.
Details of my implementation are here. The part that I'm trying to construct is this one in the view:
<p><%= link_to 'Remove friend', friendships_path(current_user.friendships.where(:friend_id => @user).last), :method => :delete %></p>
My main stumbling block is how to look up the friendship model ID for the current profile page that a given user is looking up. Obviously, I can just attach the friend's user_id to the delete link and then have the delete action of the friend controller look up the join table entry to delete it, but that doesn't seem to follow the proper RESTful model. What should my friendship_path parameter look like?
The approach above seems somewhat convoluted and the link URL it generates contains a period in it, which looks weird (and it doesn't work either):
<p><a href="/friendships.2" data-method="delete" rel="nofollow">Remove friend</a></p>