Refactor the respond_to block in Relationships controller