Description
HasFriendship adds friendship features to ActiveRecord models in a Rails application. Objects can send, accept and decline friend requests, and the gem models this with a self-referential polymorphic association. To set it up, you add has_friendship to the model, then run the rake task has_friendship_engine:install:migrations to generate the migration and apply it with rails db:migrate. The friendship table uses an integer friend_id by default, and the README says to edit the migration first if you need UUIDs or another type. After a gem upgrade, you run the install task again if new migrations are needed. The model gets helpers for pending friends, blocked friends and accepted friends. You can add custom validations by implementing a friendship_errors method on your model that returns an array of errors, and callbacks are documented in the README.…
Highlights
- Send, accept and decline friend requests
- Pending, blocked and accepted friend lists
- Custom validations for friendships
- Callbacks for friendship events
- Rails migration generator
Ratings & Reviews
No ratings yet
Be the first to rate Has Friendship.
People also visit
Has Friendship FAQ
What is HasFriendship?
A Rails gem that adds friend requests and friendships to ActiveRecord models.
How do I install it?
Add has_friendship to your model, then run rails has_friendship_engine:install:migrations and rails db:migrate.
Can I use UUIDs for friend IDs?
Yes, but the default migration uses an integer friend_id. The README says to edit the migration file before running it for another datatype.
Can I add my own rules?
Yes. Implement friendship_errors on your model to return errors that stop a friendship from being established.
What are the best Has Friendship alternatives?
Popular alternatives to Has Friendship include Acts As Messageable, Django Social Network and Friendica. See all Has Friendship alternatives









