I use devise for authentication in my web application and my web application also responds to iPhone applications. So far I have done only authentication and so when the iPhone app sends the username and password as
http://localhost:3000/login.json -d "{'user' : { 'username' : 'sample@yahoo.co.in','password' : 'password'}}"
The response would be
{“user”:{“authentication_token”:”LayzZw3s3gsNMFRJp1JR”,”email”:”sample@yahoo.co.in”,”username”:”sample@yahoo.co.in”}}
But now I need to create friendships between user from iPhone application i.e., the user have to send friend request to another user through API and the another user should receive a request
After the user accepts the request the user should be added to the friend list of both users and the friends of the user should be displayed when the user needs by calling API
How can I do this?
As m_x said this has nothing to do with authentication.
What you should create is a self referential associon between users with an has many trhough relationship.
An user has many friends trough friendship (and in the same time has many inverse_friends).
This is very well explained in railscast #163 http://railscasts.com/episodes/163-self-referential-association
In your scenario the inverse_friend should be considered as “friends request” and once a user has both a friend and an inverse friend relation with another user the “friendship” should be considered accepted.