How to send a friend request

create table friends
id int not null auto_increment,
user_id int,
friend_id int,
constraint fk_friends_accounts foreign key (user_id) references
foreign key (friend_id) references accounts(id),
primary key(id)

this is my friends tables…friend_id is the field where ids of the
user are filled but before filling that friend_id field,a request is
to be sent to the user who is supposed to be added.

here i request suggestions for how to send that friendrequest…

thanks in advance.

you can:

  • create but not activate such an entry
  • send your request
  • activate your entry by receiving the answer from the user

thank u lanzem,

can u plz explain in detail how can i send request to other user.

lets leave activation part aside for sometime.

thank u once again…

Straight from the Rails wiki:


i did see that link…Chris.

i basically want to send a ping messages to user stating that “so n so
send u a friend request” when he logs in.
Will this be possible.I even don’t know where to start.any suggestions

thank u for reply…Chris.

you can render such “received requests” into a messages-view of your
logged in user. just store the friend_request the sender created as a
FriendRequest instance, set the name of the recipient and mark this
request with a meaningfull state (e.g request_sent)

then if a user is logged in, render its “received requests” area with
something like that

@received_requests =
FriendRequest.find_by_recipient( session[:user].id )

can u plz explain in detail how can isendrequest to other user.

if I go deeper, I’ve to write code. So you should get the point.

lets leave activation part aside for sometime.

you can’t. the “activation part” is the state of your FriendRequest…