I have a Friend model:
user_id, friend_id, status (approved, pending, ignored)
Given a user currently logged in, I want to be able to do something like
current_user.friendship_exists(@user)
Something to tell if a friendship exists for a logged in user looking at another user. To prevent either user from seeing "add friend" again when the record already exists.
Ideally I could show the user who created the friendship "Friend Request Sent"
And the user who needs to take action "respond to friendship request" where I can then so a approve & reject option.
Ideas on how I can do this? Show a button for either
If you're just looking for the friendship_exists method, this is already built into Rails (assuming your User model has many friends):
current_user.friends.exists?(@user)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With