The pull request with all the code.

another example of a non RESTful api... without even looking deeply into the code below I can venture to guess that this could be exactracted into a FriendshipsController or something like that.